def handle_accept_socket_exeption(cls, error):
if error.errno in (errno.EWOULDBLOCK, errno.EAGAIN):
# Try again
return True # continue accept loop
elif error.errno == errno.EPERM:
# Netfilter on Linux may have rejected the
# connection, but we get told to try to accept()
# anyway.
return True # continue accept loop
elif error.errno in (errno.EMFILE, errno.ENOBUFS, errno.ENFILE,
errno.ENOMEM, errno.ECONNABORTED):
# Linux gives EMFILE when a process is not allowed to
# allocate any more file descriptors. *BSD and Win32
# give (WSA)ENOBUFS. Linux can also give ENFILE if the
# system is out of inodes, or ENOMEM if there is
# insufficient memory to allocate a new dentry.
# ECONNABORTED is documented as possible on all
# relevant platforms (Linux, Windows, macOS, and the
# BSDs) but occurs only on the BSDs. It occurs when a
# client sends a FIN or RST after the server sends a
# SYN|ACK but before application code calls accept(2).
# On Linux, calling accept(2) on such a listener
# returns a connection that fails as though the it were
# terminated after being fully established. This
# appears to be an implementation choice (see
# inet_accept in inet/ipv4/af_inet.c). On macOS X,
# such a listener is not considered readable, so
# accept(2) will never be called. Calling accept(2) on
# such a listener, however, does not return at all.
log.error("Could not accept new connection (%s)" % error.strerror)
return False # break accept loop
评论列表
文章目录