[Multiprocessing-sig] Shared network Queue in separate thread/process

Algirdas Brazas [Agilitus] algirdas at agilitus.lt
Tue Feb 28 14:13:16 CET 2012


Dear Sirs,

Earlier I had:

import Queue
from processing.managers import BaseManager, CreatorMethod
myQueue=Queue.Queue(50)
class QueueManager(BaseManager):
     sms_que = CreatorMethod(callable=lambda:myQueue, typeid='my_que')
m = QueueManager(address=('192.168.1.81', 50000), authkey='none')
m.start()

In 2.7, with rewrite to multiprocessing and .register I get 
"pickle.PicklingError: Can't pickle <function <lambda> at 
0x00000000028BF358>: it's not found as __parents_main__.<lambda>".
The code is:

from multiprocessing.managers import BaseManager, Queue
myQueue=Queue.Queue()
class QueueManager(BaseManager):
     pass
QueueManager.register('my_que', callable=lambda:myQueue)
m = QueueManager(address=('', 50000), authkey='none')
m.start()

I can get it to work only with m.get_server().serve_forever(), but that 
is not what I need - I need the server in separate thread/process, to be 
able to use that Queue later. The same Queue is used by clients on the 
network.

O to put the question otherwise - does anyone have recipe for shared 
network queues in 2.7?

Sincerely Yours

Algirdas Brazas


More information about the Multiprocessing-sig mailing list