From ea032b6c9c8dd5ff370057a73a762d4a7af1e897 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Mon, 19 Jul 2010 13:09:28 -0700 Subject: [PATCH] Check for EINTR in a more flexible way for compatibility with older pythons and poll implementations. Original commit: http://github.com/eklitzke/tornado/commit/31c33737c5534f21a99371bb21e02cd4791f9010 --- tornado/ioloop.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tornado/ioloop.py b/tornado/ioloop.py index f9bb1a255..c1345cb2f 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -224,7 +224,14 @@ class IOLoop(object): try: event_pairs = self._impl.poll(poll_timeout) except Exception, e: - if hasattr(e, 'errno') and e.errno == errno.EINTR: + # Depending on python version and IOLoop implementation, + # different exception types may be thrown and there are + # two ways EINTR might be signaled: + # * e.errno == errno.EINTR + # * e.args is like (errno.EINTR, 'Interrupted system call') + if (getattr(e, 'errno') == errno.EINTR or + (isinstance(getattr(e, 'args'), tuple) and + len(e.args) == 2 and e.args[0] == errno.EINTR)): logging.warning("Interrupted system call", exc_info=1) continue else: -- 2.47.2