This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mrts
Recipients jnoller, mark.dickinson, mrts
Date 2008-10-24.09:52:23
SpamBayes Score 0.0001539359
Marked as misclassified No
Message-id <1224841945.85.0.28812877642.issue3518@psf.upfronthosting.co.za>
In-reply-to
Content
I propose we add the following to that section as well.

If you need to provide access to a queue from both local and remote
processes, use `multiprocessing.Queue` in the server:

>>> from multiprocessing import Process, Queue
>>> from multiprocessing.managers import BaseManager
>>> class Worker(Process):
...     def __init__(self, q):
...         self.q = q
...         super(Worker, self).__init__()
...     def run(self):
...         self.q.put('local hello')
... 
>>> q = Queue()
>>> w = Worker(q)
>>> w.start()
>>> class QueueManager(BaseManager): pass
... 
>>> QueueManager.register('getQueue', callable=lambda: q)
>>> m = QueueManager(address=('', 50000), authkey='abracadabra')
>>> s = m.get_server()
>>> s.serve_forever()

Use it in the client as shown above:

>>> from multiprocessing.managers import BaseManager
>>> class QueueManager(BaseManager): pass
... 
>>> QueueManager.register('getQueue')
>>> m = QueueManager(address=('localhost', 50000), authkey='abracadabra')
>>> m.connect()
>>> q = m.getQueue()
>>> q.get()
'local hello'
>>> q.put('remote hello')
History
Date User Action Args
2008-10-24 09:52:26mrtssetrecipients: + mrts, mark.dickinson, jnoller
2008-10-24 09:52:25mrtssetmessageid: <1224841945.85.0.28812877642.issue3518@psf.upfronthosting.co.za>
2008-10-24 09:52:24mrtslinkissue3518 messages
2008-10-24 09:52:23mrtscreate