Multiprocessing.connection magic
Claudiu Popa
cpopa at bitdefender.com
Fri Jun 3 02:28:22 EDT 2011
Hello guys,
While working at a dispatcher using
multiprocessing.connection.Listener module I've stumbled upon some
sort of magic trick that amazed me. How is this possible and
what does multiprocessing library doing in background for this to
work?
Client, Python 2.6
>>> from multiprocessing.connection import Client
>>> client = Client(("localhost", 8080))
>>> import shutil
>>> client.send(shutil.copy)
Server, 3.2
>>> from multiprocessing.connection import Listener
>>> listener = Listener(("localhost", 8080))
>>> con = listener.accept()
>>> data = con.recv()
>>> data
<function copy at 0x024611E0>
>>> help(data)
Help on function copy in module shutil:
copy(src, dst)
Copy data and mode bits ("cp src dst").
The destination may be a directory.
>>>
More information about the Python-list
mailing list