From: schlamar Date: Tue, 6 May 2014 09:20:37 +0000 (+0200) Subject: Use constant for blocking errnos. X-Git-Tag: v4.0.0b1~84^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1044%2Fhead;p=thirdparty%2Ftornado.git Use constant for blocking errnos. --- diff --git a/tornado/netutil.py b/tornado/netutil.py index d12a21602..50e3a0b92 100644 --- a/tornado/netutil.py +++ b/tornado/netutil.py @@ -44,6 +44,11 @@ else: # thread now. u('foo').encode('idna') +# These errnos indicate that a non-blocking operation must be retried +# at a later time. On most platforms they're the same value, but on +# some they differ. +_ERRNO_WOULDBLOCK = (errno.EWOULDBLOCK, errno.EAGAIN) + def bind_sockets(port, address=None, family=socket.AF_UNSPEC, backlog=128, flags=None): """Creates listening sockets bound to the given port and address. @@ -163,9 +168,9 @@ def add_accept_handler(sock, callback, io_loop=None): try: connection, address = sock.accept() except socket.error as e: - # EWOULDBLOCK and EAGAIN indicate we have accepted every + # _ERRNO_WOULDBLOCK indicate we have accepted every # connection that is available. - if errno_from_exception(e) in (errno.EWOULDBLOCK, errno.EAGAIN): + if errno_from_exception(e) in _ERRNO_WOULDBLOCK: return # ECONNABORTED indicates that there was a connection # but it was closed while still in the accept queue.