all Python 3socketfunction
socket.getdefaulttimeout()
timeouts
Returns the default timeout for new sockets: a number of seconds, or None for waiting without a limit.
Syntax
socket.getdefaulttimeout() -> float | None
At import time the value is None: every new socket is blocking and may wait in recv() or connect() forever, a common reason for a 'frozen' script. The value applies only to sockets created after it was set, never to ones already open. Read a particular socket's timeout with its gettimeout() method, not this function.
Examples
import socket
print(socket.getdefaulttimeout()) # → None
with socket.socket() as s:
print(s.gettimeout()) # → None — ждёт без срока
See also
Common errors
Open in the full glossarydocs.python.orgReport an inaccuracy