[issue32373] Add socket.getblocking() method

Yury Selivanov report at bugs.python.org
Tue Dec 19 10:56:14 EST 2017


Yury Selivanov <yselivanov at gmail.com> added the comment:

It looks like we have a bug with 'sock.settimeout()' and non-blocking/blocking modes (or maybe this is a feature?)

Currently:

* to make a socket non-blocking, we call 'sock.settimeout(0)'.

* to make a socket blocking, we call 'sock.settimeout(None)'.


What happens if we call sock.settimeout(t), where t > 0?  The internal timeout field of the socket object will simply be set to 't'.  What happens if the socket was in a non-blocking mode?  Nothing, it stays in non-blocking mode.

What it means: suppose you have a non-blocking socket.  You call socket.settimeout(10), and most likely you wanted to make it blocking again.  Because all operations on the socket become blocking from moment (sock_call_ex repeats on EWOULDBLOCK and EAGAIN).

Now is having a timeout and blocking send/recv methods on a non-blocking socket a feature? Or is this a bug?

----------
nosy: +njs, pitrou

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


More information about the Python-bugs-list mailing list