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: timeout option of socket.create_connection is not respected
Type: behavior Stage:
Components: IO Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Nicolas SURRIBAS
Priority: normal Keywords:

Created on 2022-02-03 14:18 by Nicolas SURRIBAS, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg412443 - (view) Author: Nicolas SURRIBAS (Nicolas SURRIBAS) Date: 2022-02-03 14:18
When passing to socket.create_connection a timeout option above (approximately) 127 seconds, the timeout is not respected. 

Code to reproduce the issue :

import socket
from time import monotonic

print(socket.getdefaulttimeout())
start = monotonic()
try:
    socket.create_connection(("1.1.1.1", 21), 300)
except Exception as exception:
    print(exception)

print(monotonic() - start)

Output at execution:

None
[Errno 110] Connection timed out
129.3075186319984

Expected behavior would be that the "Connection timed out" exception is raised after 300 seconds, as given in argument, not 129.

Observed with Python 3.9.1
History
Date User Action Args
2022-04-11 14:59:55adminsetgithub: 90783
2022-02-03 14:18:19Nicolas SURRIBAScreate