Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
690ee6db
Commit
690ee6db
authored
Oct 02, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix select_test failure, remove crap old timing_test.
parent
9c8ff7ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
30 deletions
+11
-30
mitogen/core.py
mitogen/core.py
+10
-6
mitogen/master.py
mitogen/master.py
+1
-1
tests/timing_test.py
tests/timing_test.py
+0
-23
No files found.
mitogen/core.py
View file @
690ee6db
...
@@ -265,11 +265,15 @@ class Sender(object):
...
@@ -265,11 +265,15 @@ class Sender(object):
def
_queue_interruptible_get
(
queue
,
timeout
=
None
,
block
=
True
):
def
_queue_interruptible_get
(
queue
,
timeout
=
None
,
block
=
True
):
if
timeout
:
# bool is subclass of int, cannot use isinstance!
assert
timeout
is
None
or
type
(
timeout
)
in
(
int
,
long
,
float
)
assert
isinstance
(
block
,
bool
)
if
timeout
is
not
None
:
timeout
+=
time
.
time
()
timeout
+=
time
.
time
()
msg
=
None
msg
=
None
while
msg
is
None
and
(
timeout
is
None
or
timeout
<
time
.
time
()):
while
msg
is
None
and
(
timeout
is
None
or
timeout
>
time
.
time
()):
try
:
try
:
msg
=
queue
.
get
(
block
,
0.5
)
msg
=
queue
.
get
(
block
,
0.5
)
except
Queue
.
Empty
:
except
Queue
.
Empty
:
...
@@ -309,11 +313,11 @@ class Receiver(object):
...
@@ -309,11 +313,11 @@ class Receiver(object):
def
empty
(
self
):
def
empty
(
self
):
return
self
.
_queue
.
empty
()
return
self
.
_queue
.
empty
()
def
get
(
self
,
timeout
=
None
):
def
get
(
self
,
timeout
=
None
,
block
=
True
):
IOLOG
.
debug
(
'%r.
on_receive(timeout=%r)'
,
self
,
timeout
)
IOLOG
.
debug
(
'%r.
get(timeout=%r, block=%r)'
,
self
,
timeout
,
block
)
msg
=
_queue_interruptible_get
(
self
.
_queue
,
timeout
)
msg
=
_queue_interruptible_get
(
self
.
_queue
,
timeout
,
block
=
block
)
IOLOG
.
debug
(
'%r.
on_receive
() got %r'
,
self
,
msg
)
IOLOG
.
debug
(
'%r.
get
() got %r'
,
self
,
msg
)
if
msg
==
_DEAD
:
if
msg
==
_DEAD
:
raise
ChannelError
(
'Channel closed by local end.'
)
raise
ChannelError
(
'Channel closed by local end.'
)
...
...
mitogen/master.py
View file @
690ee6db
...
@@ -321,7 +321,7 @@ class Select(object):
...
@@ -321,7 +321,7 @@ class Select(object):
while
True
:
while
True
:
recv
=
mitogen
.
core
.
_queue_interruptible_get
(
self
.
_queue
,
timeout
)
recv
=
mitogen
.
core
.
_queue_interruptible_get
(
self
.
_queue
,
timeout
)
try
:
try
:
msg
=
recv
.
get
(
False
)
msg
=
recv
.
get
(
block
=
False
)
if
self
.
_oneshot
:
if
self
.
_oneshot
:
self
.
remove
(
recv
)
self
.
remove
(
recv
)
return
recv
,
msg
return
recv
,
msg
...
...
tests/timing_test.py
deleted
100644 → 0
View file @
9c8ff7ec
#!/usr/bin/env python
import
socket
import
time
import
unittest
import
mitogen.master
import
mitogen.utils
@
mitogen
.
utils
.
with_router
def
do_stuff
(
router
):
context
=
router
.
connect
(
mitogen
.
master
.
Stream
)
t0
=
time
.
time
()
ncalls
=
1000
for
x
in
xrange
(
ncalls
):
context
.
call
(
socket
.
gethostname
)
return
(
1e6
*
(
time
.
time
()
-
t0
))
/
ncalls
class
LocalContextTimingTest
(
unittest
.
TestCase
):
def
test_timing
(
self
):
self
.
assertLess
(
do_stuff
(),
1000
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment