diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-07-29 21:08:00 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-07-29 21:08:00 (GMT) |
commit | f2ed889027f23ecf184a6ef52b7a7cc4921c3000 (patch) | |
tree | 5619b13a4d5d0f1862333fcdec614b6721fb75ae /Lib/asyncio | |
parent | 3d4953a14b5b996432a8f8920d99f0ec1337b79e (diff) | |
download | cpython-f2ed889027f23ecf184a6ef52b7a7cc4921c3000.zip cpython-f2ed889027f23ecf184a6ef52b7a7cc4921c3000.tar.gz cpython-f2ed889027f23ecf184a6ef52b7a7cc4921c3000.tar.bz2 |
asyncio: Use the new os.set_blocking() function of Python 3.5 if available
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/unix_events.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index 5020cc5..8d3e25e 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -259,10 +259,14 @@ 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) +if hasattr(os, 'set_blocking'): + def _set_nonblocking(fd): + os.set_blocking(fd, False) +else: + 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): |