Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be946bf

Browse files
committed
SF patch 555085 (timeout socket implementation) by Michael Gilfix.
I've made considerable changes to Michael's code, specifically to use the select() system call directly and to store the timeout as a C double instead of a Python object; internally, -1.0 (or anything negative) represents the None from the API. I'm not 100% sure that all corner cases are covered correctly, so please keep an eye on this. Next I'm going to try it Windows before Tim complains. No way is this a bugfix candidate. :-)
1 parent 1569905 commit be946bf

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Doc/lib/libsocket.tex

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,29 @@ \subsection{Socket Objects \label{socket-objects}}
514514
block until they can proceed.
515515
\end{methoddesc}
516516

517+
\begin{methoddesc}[socket]{settimeout}{value}
518+
Set a timeout on blocking socket operations. Value can be any numeric value
519+
or \var{None}. Socket operations will raise an \exception{error} exception
520+
if the timeout period \var{value} has elapsed before the operation has
521+
completed. Setting a timeout of \var{None} disables timeouts on socket
522+
operations.
523+
\end{methoddesc}
524+
525+
\begin{methoddesc}[socket]{gettimeout}{}
526+
Returns the timeout in floating seconds associated with socket operations.
527+
A timeout of None indicates that timeouts on socket operations are
528+
disabled.
529+
\end{methoddesc}
530+
531+
Some notes on the interaction between socket blocking and timeouts:
532+
socket blocking mode takes precendence over timeouts. If a socket
533+
if set to non-blocking mode, then timeouts set on sockets are never
534+
don't mean anything. The timeout value associated with the socket
535+
can still be set via settimeout and its value retrieved via gettimeout,
536+
but the timeout is never enforced (i.e, an exception will never be
537+
thrown). Otherwise, if the socket is in blocking mode, setting the
538+
timeout will raise an exception as expected.
539+
517540
\begin{methoddesc}[socket]{setsockopt}{level, optname, value}
518541
Set the value of the given socket option (see the \UNIX{} manual page
519542
\manpage{setsockopt}{2}). The needed symbolic constants are defined in

0 commit comments

Comments
 (0)