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: socket.connect() slow to time out on Windows
Type: performance Stage: test needed
Components: Windows Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2020-07-15 21:21 by steve.dower, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg373725 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2020-07-15 21:21
When connecting to localhost, socket.connect() takes two seconds on Windows (the default) to time out, but on Linux (including WSL) it times out immediately.

Test code (assuming port 9999 has no listener):
>>> import socket
>>> socket.socket().connect(('localhost', 9999))

For a remote host, the timeout is approx 10s on Windows and 20s on WSL (I didn't test on a native Linux box).

I'm told the correct fix is to specify TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS [1] when connecting to localhost.
History
Date User Action Args
2022-04-11 14:59:33adminsetgithub: 85480
2020-07-15 21:21:16steve.dowercreate