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
671f7532
Commit
671f7532
authored
Mar 27, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: cache result of unpickling message.
parent
5b87d10a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
mitogen/core.py
mitogen/core.py
+12
-8
No files found.
mitogen/core.py
View file @
671f7532
...
...
@@ -281,6 +281,7 @@ class Message(object):
handle
=
None
reply_to
=
None
data
=
''
_unpickled
=
object
()
router
=
None
receiver
=
None
...
...
@@ -324,15 +325,18 @@ class Message(object):
def
unpickle
(
self
,
throw
=
True
,
throw_dead
=
True
):
"""Deserialize `data` into an object."""
_vv
and
IOLOG
.
debug
(
'%r.unpickle()'
,
self
)
fp
=
cStringIO
.
StringIO
(
self
.
data
)
unpickler
=
cPickle
.
Unpickler
(
fp
)
unpickler
.
find_global
=
self
.
_find_global
obj
=
self
.
_unpickled
if
obj
is
Message
.
_unpickled
:
fp
=
cStringIO
.
StringIO
(
self
.
data
)
unpickler
=
cPickle
.
Unpickler
(
fp
)
unpickler
.
find_global
=
self
.
_find_global
try
:
# Must occur off the broker thread.
obj
=
unpickler
.
load
()
except
(
TypeError
,
ValueError
),
ex
:
raise
StreamError
(
'invalid message: %s'
,
ex
)
try
:
# Must occur off the broker thread.
obj
=
unpickler
.
load
()
self
.
_unpickled
=
obj
except
(
TypeError
,
ValueError
),
ex
:
raise
StreamError
(
'invalid message: %s'
,
ex
)
if
throw
:
if
obj
==
_DEAD
and
throw_dead
:
...
...
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