[New-bugs-announce] [issue46625] timeout option of socket.create_connection is not respected

Nicolas SURRIBAS report at bugs.python.org
Thu Feb 3 09:18:19 EST 2022


New submission from Nicolas SURRIBAS <nicolas.surribas at gmail.com>:

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

----------
components: IO
messages: 412443
nosy: Nicolas SURRIBAS
priority: normal
severity: normal
status: open
title: timeout option of socket.create_connection is not respected
type: behavior
versions: Python 3.9

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


More information about the New-bugs-announce mailing list