Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
fa0f1238
Commit
fa0f1238
authored
9 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
python: run callback in main thread
parent
7b170729
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/tools/scanner.py
+6
-1
6 additions, 1 deletion
python/tools/scanner.py
with
6 additions
and
1 deletion
python/tools/scanner.py
+
6
−
1
View file @
fa0f1238
...
@@ -20,6 +20,7 @@ from pprint import pprint
...
@@ -20,6 +20,7 @@ from pprint import pprint
from
math
import
cos
,
sin
,
pi
from
math
import
cos
,
sin
,
pi
from
urllib
import
request
from
urllib
import
request
import
gzip
import
gzip
import
asyncio
sys
.
path
.
append
(
'
..
'
)
sys
.
path
.
append
(
'
..
'
)
from
opendht
import
*
from
opendht
import
*
...
@@ -96,6 +97,8 @@ all_lines = []
...
@@ -96,6 +97,8 @@ all_lines = []
plt
.
pause
(
2
)
plt
.
pause
(
2
)
loop
=
asyncio
.
get_event_loop
()
def
step
(
cur_h
,
cur_depth
):
def
step
(
cur_h
,
cur_depth
):
global
done
,
all_nodes
,
all_lines
global
done
,
all_nodes
,
all_lines
done
+=
1
done
+=
1
...
@@ -105,7 +108,7 @@ def step(cur_h, cur_depth):
...
@@ -105,7 +108,7 @@ def step(cur_h, cur_depth):
arc
=
ringx
.
add_patch
(
mpatches
.
Wedge
([
0.
,
0
,],
1.
,
a
*
180
/
pi
,
b
*
180
/
pi
,
fill
=
True
,
color
=
"
blue
"
,
alpha
=
0.5
))
arc
=
ringx
.
add_patch
(
mpatches
.
Wedge
([
0.
,
0
,],
1.
,
a
*
180
/
pi
,
b
*
180
/
pi
,
fill
=
True
,
color
=
"
blue
"
,
alpha
=
0.5
))
lines
=
ringx
.
plot
([
0
,
cos
(
a
)],
[
0
,
sin
(
a
)],
'
k-
'
,
lw
=
1.2
)
lines
=
ringx
.
plot
([
0
,
cos
(
a
)],
[
0
,
sin
(
a
)],
'
k-
'
,
lw
=
1.2
)
all_lines
.
extend
(
lines
)
all_lines
.
extend
(
lines
)
r
.
get
(
cur_h
,
gcb
,
lambda
d
,
nodes
:
nextstep
(
cur_h
,
cur_depth
,
d
,
nodes
,
arc
=
arc
,
lines
=
lines
))
r
.
get
(
cur_h
,
gcb
,
lambda
d
,
nodes
:
loop
.
call_soon_threadsafe
(
nextstep
,
cur_h
,
cur_depth
,
d
,
nodes
,
arc
,
lines
))
def
nextstep
(
cur_h
,
cur_depth
,
ok
,
nodes
,
arc
=
None
,
lines
=
[]):
def
nextstep
(
cur_h
,
cur_depth
,
ok
,
nodes
,
arc
=
None
,
lines
=
[]):
global
done
,
all_nodes
global
done
,
all_nodes
...
@@ -239,6 +242,8 @@ def d(arg):
...
@@ -239,6 +242,8 @@ def d(arg):
while
run
:
while
run
:
while
run
and
done
>
0
:
while
run
and
done
>
0
:
loop
.
stop
()
loop
.
run_forever
()
update_plot
()
update_plot
()
plt
.
draw
()
plt
.
draw
()
plt
.
pause
(.
5
)
plt
.
pause
(.
5
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment