3 import multiprocessing.queues
4 from multiprocessing.reduction
import ForkingPickler
9 """Proxy class for _multiprocessing.Connection which uses ForkingPickler to 12 def __init__(self, conn):
17 ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(obj)
18 self.send_bytes(buf.getvalue())
21 buf = self.recv_bytes()
22 return pickle.loads(buf)
24 def __getattr__(self, name):
25 if 'conn' in self.__dict__:
26 return getattr(self.
conn, name)
27 raise AttributeError(
"'{}' object has no attribute '{}'".format(
28 type(self).__name__,
'conn'))
31 class Queue(multiprocessing.queues.Queue):
33 def __init__(self, *args, **kwargs):
34 super(Queue, self).__init__(*args, **kwargs)
37 self.
_send = self._writer.send
38 self.
_recv = self._reader.recv
43 def _make_methods(self):
44 if not isinstance(self.
_reader, ConnectionWrapper):
47 super(SimpleQueue, self)._make_methods()