summaryrefslogtreecommitdiff
path: root/Lib/asyncio/unix_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-07-29 22:32:47 +0200
committerVictor Stinner <victor.stinner@gmail.com>2014-07-29 22:32:47 +0200
commit1db9e7bb19909ed56821b1580cbb024faccac041 (patch)
tree20043197ec08844340c9ac039fe26c630bd4189d /Lib/asyncio/unix_events.py
parent6aa4269ed25f7fdddd99fe1d7b09b8406ecb05ea (diff)
downloadcpython-git-1db9e7bb19909ed56821b1580cbb024faccac041.tar.gz
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.
Diffstat (limited to 'Lib/asyncio/unix_events.py')
-rw-r--r--Lib/asyncio/unix_events.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 5020cc5db5..665901ad26 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -1,7 +1,6 @@
"""Selector event loop for Unix with signal handling."""
import errno
-import fcntl
import os
import signal
import socket
@@ -259,12 +258,6 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
return server
-def _set_nonblocking(fd):
- flags = fcntl.fcntl(fd, fcntl.F_GETFL)
- flags = flags | os.O_NONBLOCK
- fcntl.fcntl(fd, fcntl.F_SETFL, flags)
-
-
class _UnixReadPipeTransport(transports.ReadTransport):
max_size = 256 * 1024 # max bytes we read in one event loop iteration
@@ -280,7 +273,7 @@ class _UnixReadPipeTransport(transports.ReadTransport):
stat.S_ISSOCK(mode) or
stat.S_ISCHR(mode)):
raise ValueError("Pipe transport is for pipes/sockets only.")
- _set_nonblocking(self._fileno)
+ os.set_blocking(self._fileno, False)
self._protocol = protocol
self._closing = False
self._loop.add_reader(self._fileno, self._read_ready)
@@ -373,7 +366,7 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
stat.S_ISCHR(mode)):
raise ValueError("Pipe transport is only for "
"pipes, sockets and character devices")
- _set_nonblocking(self._fileno)
+ os.set_blocking(self._fileno, False)
self._protocol = protocol
self._buffer = []
self._conn_lost = 0