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
df07e47d
Commit
df07e47d
authored
Feb 14, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: de-munge Message.unpickle() vs. Receiver.get().
parent
a39cd44b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
20 deletions
+17
-20
mitogen/core.py
mitogen/core.py
+15
-16
mitogen/master.py
mitogen/master.py
+2
-4
No files found.
mitogen/core.py
View file @
df07e47d
...
...
@@ -254,17 +254,27 @@ class Message(object):
self
.
data
=
cPickle
.
dumps
(
CallError
(
e
),
protocol
=
2
)
return
self
def
unpickle
(
self
):
def
unpickle
(
self
,
throw
=
True
):
"""Deserialize `data` into an object."""
IOLOG
.
debug
(
'%r.unpickle()'
,
self
)
fp
=
cStringIO
.
StringIO
(
self
.
data
)
unpickler
=
cPickle
.
Unpickler
(
fp
)
unpickler
.
find_global
=
self
.
_find_global
try
:
return
unpickler
.
load
()
# Must occur off the broker thread.
obj
=
unpickler
.
load
()
except
(
TypeError
,
ValueError
),
ex
:
raise
StreamError
(
'invalid message: %s'
,
ex
)
if
throw
:
if
obj
==
_DEAD
:
raise
ChannelError
(
ChannelError
.
remote_msg
)
if
isinstance
(
obj
,
CallError
):
raise
obj
return
obj
def
__repr__
(
self
):
return
'Message(%r, %r, %r, %r, %r, %r..%d)'
%
(
self
.
dst_id
,
self
.
src_id
,
self
.
auth_id
,
self
.
handle
,
...
...
@@ -358,19 +368,7 @@ class Receiver(object):
if
msg
==
_DEAD
:
raise
ChannelError
(
ChannelError
.
local_msg
)
# Must occur off the broker thread.
data
=
msg
.
unpickle
()
if
data
==
_DEAD
and
self
.
raise_channelerror
:
raise
ChannelError
(
ChannelError
.
remote_msg
)
if
isinstance
(
data
,
CallError
):
raise
data
return
msg
,
data
def
get_data
(
self
,
timeout
=
None
):
return
self
.
get
(
timeout
)[
1
]
return
msg
def
__iter__
(
self
):
while
True
:
...
...
@@ -1230,7 +1228,8 @@ class ExternalContext(object):
fp
.
close
()
def
_dispatch_calls
(
self
):
for
msg
,
data
in
self
.
channel
:
for
msg
in
self
.
channel
:
data
=
msg
.
unpickle
(
throw
=
False
)
LOG
.
debug
(
'_dispatch_calls(%r)'
,
data
)
if
msg
.
src_id
not
in
mitogen
.
parent_ids
:
LOG
.
warning
(
'CALL_FUNCTION from non-parent %r'
,
msg
.
src_id
)
...
...
mitogen/master.py
View file @
df07e47d
...
...
@@ -564,17 +564,15 @@ class Context(mitogen.core.Context):
else:
klass = None
re
cv =
self.send_async(
re
turn
self.send_async(
mitogen.core.Message.pickled(
(fn.__module__, klass, fn.__name__, args, kwargs),
handle=mitogen.core.CALL_FUNCTION,
)
)
recv.raise_channelerror = False
return recv
def call(self, fn, *args, **kwargs):
return self.call_async(fn, *args, **kwargs).get
_data
()
return self.call_async(fn, *args, **kwargs).get
().unpickle
()
class Router(mitogen.parent.Router):
...
...
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