This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: (XMLRPC) multitude of sockets ending up in TIME_WAIT
Type: Stage:
Components: Windows Versions:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, jonsv322, loewis
Priority: normal Keywords:

Created on 2005-02-25 18:00 by jonsv322, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg24365 - (view) Author: Jonas Widén (jonsv322) Date: 2005-02-25 18:00
A problem with a multitude of sockets ending up in
TIME_WAIT when stressing a system with XML-RPC calls.
This can cause a Windows network to missbehave.

A solution on Windows platform is to set the sockopt
NOLINGER with parameters (1, 0) for the socket before
the socket is closed. This vill cause that Windows will
release the socket direct without going into TIME_WAIT.

The solution in code:
In httplib.py@somewhere:
NOLINGER = struct.pack('HH', 1, 0) # Release the
resource back to the system if socket closed

In httplib.py@632:
self.sock.setsockopt(socket.SOL_SOCKET,
socket.SO_LINGER, NOLINGER)
self.sock.close()   # close it manually... there may be
other refs
msg24366 - (view) Author: Jonas Widén (jonsv322) Date: 2005-02-25 20:13
Logged In: YES 
user_id=352221

Read section, SO_LINGER at following address:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wspsetsockopt_2.asp
msg24367 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-02-25 20:53
Logged In: YES 
user_id=21627

Why do you want to avoid the TIME_WAIT state, and why do you
think it is a Python bug that it doesn't? See

http://www.developerweb.net/sock-faq/detail.php?id=13

where Richard Stevens himself explains that SO_LINGER should
*not* be used.

It might be that SO_REUSEADDR is sufficient, see

http://www.developerweb.net/sock-faq/detail.php?id=44

If you want xmlrpclib to use different socket options, you
should subclass httplib.HTTP to redefine either connect() or
close(), and you should subclass xmlrpclib.Transport to use
your subclassed transport.
msg24368 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-03-17 19:29
Logged In: YES 
user_id=849994

Seems like Not a Bug.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41621
2005-02-25 18:00:50jonsv322create