Minimizing Connection reset by peer exceptions

Steve Holden steve at holdenweb.com
Thu Oct 20 06:48:37 EDT 2005


Ben Sizer wrote:
> mirandacascade at yahoo.com wrote:
> 
> 
>>Occasionally (perhaps 5% of the time) the following exception gets
>>raised:
>>
>>(10054, 'Connection reset by peer')
> 
> 
> Generally this just means the connection has closed through some
> unusual means, perhaps by being turned off, or a network cable being
> unplugged, or a timeout along the way, etc. 5% is a high figure, but
> perhaps you connect to hosts that are unreliable for some reason.
> 
> You don't have control over this really; just make sure you handle the
> exception. Such is life, when dealing with networking.
> 
Do note, though, that if you aren't using some means (threading, 
forking, etc) of handling the connections asynchronously then your 
server will normally only queue a very limited number of connections 
(usually 5 at most).

So if your service takes a while to run then it's possible that 
connection requests will be rejected when the queue is full, which might 
*possibly* result in the error you are seeing.

Feel free to ignore this if you only have one client at a time.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list