From: Ben Darnell Date: Mon, 19 Jul 2010 20:09:28 +0000 (-0700) Subject: Check for EINTR in a more flexible way for compatibility with older pythons X-Git-Tag: v1.0.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea032b6c9c8dd5ff370057a73a762d4a7af1e897;p=thirdparty%2Ftornado.git 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 --- 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: