Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2104,19 +2104,20 @@ callables with the manager class. For example::


Using a remote manager
""""""""""""""""""""""
"""""""""""""""""""""""

It is possible to run a manager server on one machine and have clients use it
from other machines (assuming that the firewalls involved allow it).

Running the following commands creates a server for a single shared queue which
remote clients can access::

>>> from multiprocessing import Manager
>>> from multiprocessing.managers import BaseManager
>>> from queue import Queue
>>> queue = Queue()
>>> manager = Manager()
>>> queue = manager.Queue()
>>> class QueueManager(BaseManager): pass
>>> QueueManager.register('get_queue', callable=lambda:queue)
>>> QueueManager.register('get_queue', callable=lambda: queue)
>>> m = QueueManager(address=('', 50000), authkey=b'abracadabra')
>>> s = m.get_server()
>>> s.serve_forever()
Expand Down Expand Up @@ -2145,7 +2146,7 @@ Another client can also use it::
Local processes can also access that queue, using the code from above on the
client to access it remotely::

>>> from multiprocessing import Process, Queue
>>> from multiprocessing import Process, Manager
>>> from multiprocessing.managers import BaseManager
>>> class Worker(Process):
... def __init__(self, q):
Expand All @@ -2154,7 +2155,8 @@ client to access it remotely::
... def run(self):
... self.q.put('local hello')
...
>>> queue = Queue()
>>> manager = Manager()
>>> queue = manager.Queue()
>>> w = Worker(queue)
>>> w.start()
>>> class QueueManager(BaseManager): pass
Expand Down
Loading