Commit 3112ac9a authored by Guido van Rossum's avatar Guido van Rossum

I ran a test, and sharing a pickler, even a fast one, between threads,

is *not* thread-safe.  So don't share the Pickler.
parent cf112582
...@@ -23,16 +23,11 @@ from ZEO.zrpc.log import log ...@@ -23,16 +23,11 @@ from ZEO.zrpc.log import log
class Marshaller: class Marshaller:
"""Marshal requests and replies to second across network""" """Marshal requests and replies to second across network"""
# It's okay to share a single Pickler as long as it's in fast
# mode, which means that it doesn't have a memo.
pickler = cPickle.Pickler()
pickler.fast = 1
pickle = pickler.dump
def encode(self, msgid, flags, name, args): def encode(self, msgid, flags, name, args):
"""Returns an encoded message""" """Returns an encoded message"""
return self.pickle((msgid, flags, name, args), 1) pickler = cPickle.Pickler()
pickler.fast = 1
return pickler.dump((msgid, flags, name, args), 1)
def decode(self, msg): def decode(self, msg):
"""Decodes msg and returns its parts""" """Decodes msg and returns its parts"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment