classification
Title: multiprocessing: BaseManager.from_address documented but doesn't exist
Type: Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: asksol, cmcginty, jnoller, mark.dickinson, mrts, python-dev, sbt
Priority: normal Keywords:

Created on 2008-08-07 17:46 by mark.dickinson, last changed 2012-06-11 17:34 by sbt. This issue is now closed.

Messages (7)
msg70844 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) 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) * (Python committer) 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
History
Date User Action Args
2014-06-29 10:41:48berker.peksaglinkissue5862 superseder
2012-06-11 17:34:35sbtsetstatus: open -> closed
stage: resolved
2012-06-11 16:57:52python-devsetnosy: + python-dev
messages: + msg162628
2012-06-10 17:29:36r.david.murraysetassignee: jnoller ->

nosy: + sbt
versions: + Python 2.7, Python 3.2, Python 3.3, - Python 2.6, Python 3.0
2010-08-27 14:05:30asksolsetnosy: + asksol
2009-07-09 22:45:25jnollersetstatus: closed -> open
resolution: fixed -> accepted
2009-07-09 22:39:58cmcgintysetnosy: + cmcginty
messages: + msg90359
2008-11-28 18:48:55jnollersetstatus: open -> closed
resolution: fixed
messages: + msg76546
2008-10-24 09:52:24mrtssetmessages: + msg75156
2008-10-23 11:55:12mrtssetmessages: + msg75141
2008-10-23 11:17:29mrtssetnosy: + mrts
messages: + msg75140
2008-08-07 17:46:07mark.dickinsoncreate