asyncio: Use the new os.set_blocking() function of Python 3.5 if available

This commit is contained in:
Victor Stinner 2014-07-29 23:08:00 +02:00
parent 3d4953a14b
commit f2ed889027
2 changed files with 14 additions and 10 deletions

View file

@ -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):