asyncore.dispatcher stops listening

Daniel Walton walton.dan at gmail.com
Mon Sep 4 22:03:09 EDT 2006


I have been working on a problem for a full week now.  If someone
could please help me it would be great.  Even a clue would be great at
this point.  What I am seeing is quite a mystery.

I have server written in python using asyncore.dispatcher.  It listens
on port 9940 and does something like this on handle_accept

    def handle_accept (self):
        self.log("accept")
        conn, addr = self.accept()
        self.handlers += [asynchat.async_chat_subclass(conn,addr)]

I launch the server and test the server.  Everything looks great aside
from a few functions that are a bit slow.

The server goes into use and receives some traffic for about 3 days
and then it stops listening.  telneting to the port times out.
clients (8 or so) that are connected time out.  The process is still
running.  Its not taking lots of CPU or memory.  I can start a new
server on the port without being told that something else is using it.

When I send the server a kill -SIGINT  I get this call stack in the log
Traceback (most recent call last):
  File "./link_server.py", line 975, in ?
    main(sys.argv)
  File "./link_server.py", line 973, in main
    asyncore.loop()
  File "/usr/local/lib/python2.4/asyncore.py", line 192, in loop
    poll_fun(timeout, map)
  File "/usr/local/lib/python2.4/asyncore.py", line 122, in poll
    r, w, e = select.select(r, w, e, timeout)
KeyboardInterrupt

The only other detail that might be interesting is that I am starting
the server with a
nohup some_server.py > log &

What would cause a socket to quit listening?  Any clue,
ideas,techniques, or experiences at all would be really helpful.

Thank you all very very much.
dan



More information about the Python-list mailing list