multiprocessing BaseManager doesn't clean up net connections?

Chris Brooks cab938 at
Thu Jan 1 03:01:50 CET 2009


I'm trying to use remote managers in the multiprocessing module to listen
for some events synchronously while my program goes off and does other
things.  I use the .start() method which forks a new process to handle
communication.  When I catch the sigint and call sys.exit() though, the
network port is still bound even after the python interpretor finishes. 
Here is my short code and the output:

from multiprocessing.managers import BaseManager
import threading
import sys
import signal
import time

class WorkManager(BaseManager):
    def __init__(self):
        BaseManager.__init__(self,address=('', 51114), authkey='chris')
        self.register('get_string', callable=self.getString)
    def getString(self):
        return "hi"

manager = WorkManager()

def quit( arg1, arg2 ):
signal.signal(signal.SIGINT, quit)

#busy wait
while 1:

cab938 at ubuntu:~$ python2.6 
^Ccab938 at ubuntu:~$ python2.6 
Process WorkManager-1:
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/multiprocessing/", line 231, in
  File "/usr/local/lib/python2.6/multiprocessing/", line 88, in
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python2.6/multiprocessing/", line 517, in
    server = cls._Server(registry, address, authkey, serializer)
  File "/usr/local/lib/python2.6/multiprocessing/", line 136, in
    self.listener = Listener(address=address, backlog=5)
  File "/usr/local/lib/python2.6/multiprocessing/", line 97, in
    self._listener = SocketListener(address, family, backlog)
  File "/usr/local/lib/python2.6/multiprocessing/", line 217,
in __init__
  File "<string>", line 1, in bind
error: [Errno 98] Address already in use
Traceback (most recent call last):
  File "", line 16, in <module>
  File "/usr/local/lib/python2.6/multiprocessing/", line 499, in
    self._address = reader.recv()
cab938 at ubuntu:~$ 

Comments?  Is this a bug, or is there a better way to clean up the manager
myself before shutting down?

View this message in context:
Sent from the Python - python-list mailing list archive at

More information about the Python-list mailing list