How do I send connection objects using Pipe() in python? -


i not able send pipe objects between processes.

pipe_i.send(diff_connection_object) 

i know connection objects not pickalable. send() takes argument picklable objects not able send connection object. how can ?

if use fork of multiprocessing called multiprocess should work connection object want send. fork uses dill instead of pickle, provide better serialization. example, here's sqlite3.connection object.

>>> import sqlite3 >>> c = sqlite3.connect(':memory:') >>> c <sqlite3.connection object @ 0x1046134b8> >>> import multiprocess >>> p1,p2 = multiprocess.pipe() >>> p1.send(c) >>> c_ = p2.recv() >>> c_ <sqlite3.connection object @ 0x104af8200> 

it's unclear connection object the connection object being asked about. here's _multiprocess.connection object being passed pipe multiprocess.

>>> c = p1.__class__  >>> p1.send(c) >>> c_ = p2.recv() >>> c_ <type '_multiprocess.connection'> 

however, in trying pass _multiprocess.connection object instance, instead of _multiprocess.connection object class… send works fine, recv unfortunately fail unpickle object.

>>> p3,p4 = multiprocess.pipe() >>> p1.send(p3) >>> p3_ = p2.recv() traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "/users/mmckerns/lib/python2.7/site-packages/dill-0.2.5.dev0-py2.7.egg/dill/dill.py", line 259, in loads     return load(file)   file "/users/mmckerns/lib/python2.7/site-packages/dill-0.2.5.dev0-py2.7.egg/dill/dill.py", line 249, in load     obj = pik.load()   file "/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/pickle.py", line 864, in load     dispatch[key](self)   file "/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/pickle.py", line 1089, in load_newobj     obj = cls.__new__(cls, *args) typeerror: required argument 'handle' (pos 1) not found >>>  

if last case worked, pretty cool stuff, think. maybe it's worth submitting ticket dill or multiprocess, , requesting work?


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -