[New-bugs-announce] [issue41308] socket.connect() slow to time out on Windows

Steve Dower report at bugs.python.org
Wed Jul 15 17:21:16 EDT 2020


New submission from Steve Dower <steve.dower at python.org>:

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.

----------
components: Windows
messages: 373725
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
stage: test needed
status: open
title: socket.connect() slow to time out on Windows
type: performance
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41308>
_______________________________________


More information about the New-bugs-announce mailing list