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
afc86972
Commit
afc86972
authored
Feb 18, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: Ensure add_handler() callbacks really receive _DEAD on shutdown
parent
de1b3602
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
+32
-0
mitogen/core.py
mitogen/core.py
+3
-0
mitogen/master.py
mitogen/master.py
+3
-0
tests/router_test.py
tests/router_test.py
+26
-0
No files found.
mitogen/core.py
View file @
afc86972
...
...
@@ -1003,6 +1003,9 @@ class Router(object):
for
context
in
self
.
_context_by_id
.
itervalues
():
context
.
on_shutdown
(
self
.
broker
)
for
_
,
func
in
self
.
_handle_map
.
itervalues
():
func
(
_DEAD
)
def
add_route
(
self
,
target_id
,
via_id
):
_v
and
LOG
.
debug
(
'%r.add_route(%r, %r)'
,
self
,
target_id
,
via_id
)
try
:
...
...
mitogen/master.py
View file @
afc86972
...
...
@@ -660,6 +660,9 @@ class IdAllocator(object):
self.lock.release()
def on_allocate_id(self, msg):
if msg == mitogen.core._DEAD:
return
id_ = self.allocate()
requestee = self.router.context_by_id(msg.src_id)
allocated = self.router.context_by_id(id_, msg.src_id)
...
...
tests/router_test.py
0 → 100644
View file @
afc86972
import
Queue
import
subprocess
import
time
import
unittest2
import
testlib
import
mitogen.master
import
mitogen.utils
mitogen
.
utils
.
log_to_file
()
class
AddHandlerTest
(
unittest2
.
TestCase
):
klass
=
mitogen
.
master
.
Router
def
test_invoked_at_shutdown
(
self
):
router
=
self
.
klass
()
queue
=
Queue
.
Queue
()
handle
=
router
.
add_handler
(
queue
.
put
)
router
.
broker
.
shutdown
()
self
.
assertEquals
(
queue
.
get
(
timeout
=
5
),
mitogen
.
core
.
_DEAD
)
if
__name__
==
'__main__'
:
unittest2
.
main
()
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