question about multiprocessing
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue Jun 22 07:49:40 EDT 2010
En Sun, 20 Jun 2010 09:43:09 -0300, hywhy <hywhy at live.com> escribió:
> from multiprocessing.managers import BaseManager
> import Queue
>
> class CrawlerManager(BaseManager):
> pass
>
> downloader_queue = Queue.Queue()
> downloader_queue.put('hello')
>
> CrawlerManager.register('get_downloader_queue', callable=lambda:
> downloader_queue)
>
> mgr = CrawlerManager()
> mgr.start()
>
> q = mgr.get_downloader_queue()
>
>
>
> error:
>
> pickle.PicklingError: Can't pickle <function <lambda> at 0x00C02F70>:
> it's
> not found as __parents_main__.<lambda>
Multiprocessing uses pickle to transfer data between processes. You can't
pickle a lambda expression - functions must have a name and be available
at the outermost module level. (See "Programming guidelines" in the
multiprocessing documentation, and the pickle module)
But you can't share a Queue object - use the multiprocessing one (see
"Exchanging data between processes").
--
Gabriel Genellina
More information about the Python-list
mailing list