]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Check for EINTR in a more flexible way for compatibility with older pythons
authorBen Darnell <bdarnell@beaker.local>
Mon, 19 Jul 2010 20:09:28 +0000 (13:09 -0700)
committerBen Darnell <bdarnell@beaker.local>
Mon, 19 Jul 2010 20:09:28 +0000 (13:09 -0700)
and poll implementations.

Original commit:
http://github.com/eklitzke/tornado/commit/31c33737c5534f21a99371bb21e02cd4791f9010

tornado/ioloop.py

index f9bb1a255af798a58cfbfad26951ca4d22455508..c1345cb2f6b81766884886e61010945e10f038a6 100644 (file)
@@ -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: