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
c6711950
Commit
c6711950
authored
Sep 18, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep allocate_id() in the enhanced router class.
parent
02a37d23
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
8 deletions
+18
-8
mitogen/core.py
mitogen/core.py
+0
-5
mitogen/master.py
mitogen/master.py
+13
-0
tests/data/id_allocation.py
tests/data/id_allocation.py
+5
-3
No files found.
mitogen/core.py
View file @
c6711950
...
...
@@ -868,11 +868,6 @@ class Router(object):
return
handle
def
allocate_id
(
self
):
master
=
Context
(
self
,
0
)
reply
=
master
.
send_await
(
Message
(
dst_id
=
0
,
handle
=
ALLOCATE_ID
))
return
reply
.
unpickle
()
def
on_shutdown
(
self
,
broker
):
"""Called during :py:meth:`Broker.shutdown`, informs callbacks
registered with :py:meth:`add_handle_cb` the connection is dead."""
...
...
mitogen/master.py
View file @
c6711950
...
...
@@ -739,6 +739,7 @@ METHOD_NAMES = {
def
upgrade_router
(
econtext
):
if
not
isinstance
(
econtext
.
router
,
Router
):
# TODO
econtext
.
router
.
__class__
=
Router
# TODO
econtext
.
router
.
id_allocator
=
ChildIdAllocator
(
econtext
.
router
)
LOG
.
debug
(
'_proxy_connect(): constructing ModuleForwarder'
)
ModuleForwarder
(
econtext
.
router
,
econtext
.
parent
,
econtext
.
importer
)
...
...
@@ -785,6 +786,18 @@ class IdAllocator(object):
)
class
ChildIdAllocator
(
object
):
def
__init__
(
self
,
router
):
self
.
router
=
router
def
allocate
(
self
):
master
=
Context
(
self
.
router
,
0
)
reply
=
master
.
send_await
(
mitogen
.
core
.
Message
(
dst_id
=
0
,
handle
=
mitogen
.
core
.
ALLOCATE_ID
)
)
return
reply
.
unpickle
()
class
Router
(
mitogen
.
core
.
Router
):
debug
=
False
...
...
tests/data/id_allocation.py
View file @
c6711950
import
mitogen.core
import
mitogen.master
@
mitogen
.
core
.
takes_router
def
allocate_an_id
(
router
):
return
router
.
allocate_id
()
@
mitogen
.
core
.
takes_econtext
def
allocate_an_id
(
econtext
):
mitogen
.
master
.
upgrade_router
(
econtext
)
return
econtext
.
router
.
allocate_id
()
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