From a6740e3101ce759590d4d7ca3ebe99e5d707abb5 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 18 Jan 2015 16:20:55 -0500 Subject: [PATCH] Work around an occasional EPROTOTYPE error on OSX. --- tornado/iostream.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tornado/iostream.py b/tornado/iostream.py index d14ec0fdb..640198d87 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -68,6 +68,14 @@ _ERRNO_CONNRESET = (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE, if hasattr(errno, "WSAECONNRESET"): _ERRNO_CONNRESET += (errno.WSAECONNRESET, errno.WSAECONNABORTED, errno.WSAETIMEDOUT) +if sys.platform == 'darwin': + # OSX appears to have a race condition that causes send(2) to return + # EPROTOTYPE if called while a socket is being torn down: + # http://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/ + # Since the socket is being closed anyway, treat this as an ECONNRESET + # instead of an unexpected error. + _ERRNO_CONNRESET += (errno.EPROTOTYPE,) + # More non-portable errnos: _ERRNO_INPROGRESS = (errno.EINPROGRESS,) -- 2.47.2