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
10230f62
Commit
10230f62
authored
Feb 14, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: Message.reply() helper function
parent
6fc8fa5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
29 deletions
+13
-29
mitogen/core.py
mitogen/core.py
+8
-8
mitogen/master.py
mitogen/master.py
+5
-21
No files found.
mitogen/core.py
View file @
10230f62
...
...
@@ -255,6 +255,12 @@ class Message(object):
self
.
data
=
cPickle
.
dumps
(
CallError
(
e
),
protocol
=
2
)
return
self
def
reply
(
self
,
data
,
**
kwargs
):
kwargs
.
setdefault
(
'handle'
,
self
.
reply_to
)
self
.
router
.
route
(
self
.
pickled
(
data
,
dst_id
=
self
.
src_id
,
**
kwargs
)
)
def
unpickle
(
self
,
throw
=
True
):
"""Deserialize `data` into an object."""
IOLOG
.
debug
(
'%r.unpickle()'
,
self
)
...
...
@@ -1249,16 +1255,10 @@ class ExternalContext(object):
kwargs
.
setdefault
(
'econtext'
,
self
)
if
getattr
(
fn
,
'mitogen_takes_router'
,
None
):
kwargs
.
setdefault
(
'router'
,
self
.
router
)
ret
=
fn
(
*
args
,
**
kwargs
)
self
.
router
.
route
(
Message
.
pickled
(
ret
,
dst_id
=
msg
.
src_id
,
handle
=
msg
.
reply_to
)
)
msg
.
reply
(
fn
(
*
args
,
**
kwargs
))
except
Exception
,
e
:
LOG
.
debug
(
'_dispatch_calls: %s'
,
e
)
e
=
CallError
(
e
)
self
.
router
.
route
(
Message
.
pickled
(
e
,
dst_id
=
msg
.
src_id
,
handle
=
msg
.
reply_to
)
)
msg
.
reply
(
CallError
(
e
))
self
.
dispatch_stopped
=
True
def
main
(
self
,
parent_ids
,
context_id
,
debug
,
profiling
,
log_level
,
...
...
mitogen/master.py
View file @
10230f62
...
...
@@ -489,13 +489,8 @@ class ModuleResponder(object):
def _send_load_module(self, stream, msg, fullname):
LOG.debug('
_send_load_module
(
%
r
,
%
r
)
', stream, fullname)
self._router.route(
mitogen.core.Message.pickled(
self._build_tuple(fullname),
dst_id=msg.src_id,
handle=mitogen.core.LOAD_MODULE,
)
)
msg.reply(self._build_tuple(fullname),
handle=mitogen.core.LOAD_MODULE)
stream.sent_modules.add(fullname)
def _on_get_module(self, msg):
...
...
@@ -526,13 +521,8 @@ class ModuleResponder(object):
except Exception:
LOG.debug('
While
importing
%
r', fullname, exc_info=True)
self._router.route(
mitogen.core.Message.pickled(
(fullname, None, None, None, []),
dst_id=msg.src_id,
handle=msg.reply_to,
)
)
msg.reply((fullname, None, None, None, []),
handle=mitogen.core.LOAD_MODULE)
class Broker(mitogen.core.Broker):
...
...
@@ -651,13 +641,7 @@ class IdAllocator(object):
allocated = self.router.context_by_id(id_, msg.src_id)
LOG.debug('
%
r
:
allocating
%
r
to
%
r', self, allocated, requestee)
self.router.route(
mitogen.core.Message.pickled(
id_,
dst_id=msg.src_id,
handle=msg.reply_to,
)
)
msg.reply(id_)
LOG.debug('
%
r
:
publishing
route
to
%
r
via
%
r', self,
allocated, requestee)
...
...
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