diff options
author | Rafael H. Schloming <rhs@apache.org> | 2012-07-30 23:03:46 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2012-07-30 23:03:46 +0000 |
commit | ae8e2a63a48536e90053bfdc7c4d71edd1ec1c7c (patch) | |
tree | 1082eba544c0c2edfcd3516573e8b569f4abe4c2 | |
parent | 3f3d5165649e78bba094dce6443ff9eeeb56af0c (diff) | |
download | qpid-python-ae8e2a63a48536e90053bfdc7c4d71edd1ec1c7c.tar.gz |
QPID-4147: made selector handle interrupt based on patch from siddesh
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1367354 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/python/qpid/selector.py | 24 | ||||
-rw-r--r-- | qpid/python/qpid/tests/messaging/endpoints.py | 12 |
2 files changed, 30 insertions, 6 deletions
diff --git a/qpid/python/qpid/selector.py b/qpid/python/qpid/selector.py index ca5946c3f9..ff94091da0 100644 --- a/qpid/python/qpid/selector.py +++ b/qpid/python/qpid/selector.py @@ -16,7 +16,7 @@ # specific language governing permissions and limitations # under the License. # -import atexit, time +import atexit, time, errno from compat import select, set, selectable_waiter from threading import Thread, Lock @@ -111,12 +111,24 @@ class Selector: else: wakeup = min(wakeup, t) - if wakeup is None: - timeout = None - else: - timeout = max(0, wakeup - time.time()) + rd = [] + wr = [] + ex = [] - rd, wr, ex = select(self.reading, self.writing, (), timeout) + while True: + try: + if wakeup is None: + timeout = None + else: + timeout = max(0, wakeup - time.time()) + rd, wr, ex = select(self.reading, self.writing, (), timeout) + break + except Exception, (err, strerror): + # Repeat the select call if we were interrupted. + if err == errno.EINTR: + continue + else: + raise for sel in wr: if sel.writing(): diff --git a/qpid/python/qpid/tests/messaging/endpoints.py b/qpid/python/qpid/tests/messaging/endpoints.py index 62deacd0bd..a82a9e95ed 100644 --- a/qpid/python/qpid/tests/messaging/endpoints.py +++ b/qpid/python/qpid/tests/messaging/endpoints.py @@ -1333,3 +1333,15 @@ class SenderTests(Base): self.drain(self.rcv, expected=msgs) self.ssn.acknowledge() assert caught, "did not exceed capacity" + + def testEINTR(self): + m1 = self.content("testEINTR", 0) + m2 = self.content("testEINTR", 1) + + self.snd.send(m1, timeout=self.timeout()) + try: + os.setuid(500) + assert False, "setuid should fail" + except: + pass + self.snd.send(m2, timeout=self.timeout()) |