Issue #22054: Add os.get_blocking() and os.set_blocking() functions to get and

set the blocking mode of a file descriptor (False if the O_NONBLOCK flag is
set, True otherwise). These functions are not available on Windows.
This commit is contained in:
Victor Stinner 2014-07-29 22:32:47 +02:00
parent 6aa4269ed2
commit 1db9e7bb19
13 changed files with 198 additions and 58 deletions

View file

@ -807,6 +807,17 @@ as internal buffering of data.
Availability: Unix.
.. function:: get_blocking(fd)
Get the blocking mode of the file descriptor: ``False`` if the
:data:`O_NONBLOCK` flag is set, ``True`` if the flag is cleared.
See also :func:`set_blocking` and :meth:`socket.socket.setblocking`.
Availability: Unix.
.. versionadded:: 3.5
.. function:: isatty(fd)
Return ``True`` if the file descriptor *fd* is open and connected to a
@ -1107,6 +1118,18 @@ or `the MSDN <http://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Window
.. versionadded:: 3.3
.. function:: set_blocking(fd, blocking)
Set the blocking mode of the specified file descriptor. Set the
:data:`O_NONBLOCK` flag if blocking is ``False``, clear the flag otherwise.
See also :func:`get_blocking` and :meth:`socket.socket.setblocking`.
Availability: Unix.
.. versionadded:: 3.5
.. data:: SF_NODISKIO
SF_MNOWAIT
SF_SYNC