msg70844 - (view) |
Author: Mark Dickinson (mark.dickinson) *  |
Date: 2008-08-07 17:46 |
The BaseManager.from_address method is documented at: http://docs.python.org/dev/library/multiprocessing.html#multiprocessing.ma nagers.BaseManager.from_address but it looks as though this method doesn't actually exist. In contrast, the BaseManager.connect method appears to be necessary for making remote connections, but is not documented. |
|
|
msg75140 - (view) |
Author: Mart Sõmermaa (mrts) |
Date: 2008-10-23 11:17 |
The documentation should be amended as follows: Running the following commands creates a server for a single shared queue which remote clients can access: >>> from multiprocessing.managers import BaseManager >>> import Queue >>> queue = Queue.Queue() >>> class QueueManager(BaseManager): pass ... >>> QueueManager.register('getQueue', callable=lambda:queue) >>> m = QueueManager(address=('', 50000), authkey='abracadabra') >>> s = m.get_server() >>> s.serve_forever() One client can access the server as follows: >>> 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.put('hello') Another client can also use it: >>> 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() |
|
|
msg75141 - (view) |
Author: Mart Sõmermaa (mrts) |
Date: 2008-10-23 11:55 |
Also, it would be helpful to elaborate a bit more on: major: * how to implement a queue that is shared both locally and remotely (i.e. n local processes access the queue as well as m remote processes) minor: * blocking (assumption: q.get() blocks on socket.recv()) * timeout (assumption: the socket does not time out, e.g. q.get() blocks endlessly on socket.recv()) |
|
|
msg75156 - (view) |
Author: Mart Sõmermaa (mrts) |
Date: 2008-10-24 09:52 |
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') |
|
|
msg76546 - (view) |
Author: Jesse Noller (jnoller) *  |
Date: 2008-11-28 18:48 |
Added the mp.managers shared queue example, fixed the docs in r67419 on trunk. merged to py3k and 2.6.1 maint |
|
|
msg90359 - (view) |
Author: Casey McGinty (cmcginty) |
Date: 2009-07-09 22:39 |
I would like to open this ticket back up. Python 2.6.2 docs still reference unimplemented 'from_address' method. http://docs.python.org/library/multiprocessing.html#multiprocessing.managers.BaseManager.from_address BaseManager.__reduce__ method also calls unimplemented 'from_address' method. This looks like a bug since there is no docs or comments that indicate it is as an abstract method. |
|
|
msg162628 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2012-06-11 16:57 |
New changeset c2910971eb86 by Richard Oudkerk in branch 'default': Issue #3518: Remove references to non-existent BaseManager.from_address() http://hg.python.org/cpython/rev/c2910971eb86 |
|
|