SocketServer - Connection Reset By Peer (Randomly)

Moshe Zadka m at moshez.org
Thu Jun 12 13:45:18 EDT 2003


On Thu, 12 Jun 2003, "Graeme Matthew" <gsmatthew at ozemail.com.au> wrote:

> I am using Python's SocketServer.ThreadingTCPServer. It all works fine up to
> a point.
...
> I can sometimes submit the webpage (controller.py) 10 times without an
> Internal Server Error, and sometimes 3, its random, the http log files says:
> 
> 
> File "/www/bi/cgi-bin/controller.py",line 30, in ?
> response = sock.recv(1024)
> socket.error: (104, 'Connection reset by peer')

It looks like you have a problem with the application server: it closes
the connection down. socket.recv dutifully informs you of that.
So, the application server is what I suspect. You have not shown any
code from it, so it is hard to pinpoint your problem.

One question: why are you using a home-grown solution for passing
objects between Python applications instead of using something like
Pyro, CORBA, Twisted's perspective broker or XML-RPC? You are usually
better off *not* reinventing wheels.

Further debugging tips: take the webserver out of the question by
making controller.py be a command line script, and run it in a tight
loop. Then, put lots and lots of prints in your application server
(or maybe run it under PDB, though it might get tricky with threads)
to see where the problem is. But, again, my suggestion: go with tried
and true solutions.

-- 
Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/





More information about the Python-list mailing list