summaryrefslogtreecommitdiff
path: root/python/qpid
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2012-07-30 23:03:46 +0000
committerRafael H. Schloming <rhs@apache.org>2012-07-30 23:03:46 +0000
commitbfc8a0ece32c8e52288563c0c6e3a01be81cb60f (patch)
treee74edb1ea6477f795e0d41a9755e4cda50f561ba /python/qpid
parent1de9295b0d53e3c176f86f0ffcf318cef055c661 (diff)
downloadqpid-python-bfc8a0ece32c8e52288563c0c6e3a01be81cb60f.tar.gz
QPID-4147: made selector handle interrupt based on patch from siddesh
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1367354 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid')
-rw-r--r--python/qpid/selector.py24
-rw-r--r--python/qpid/tests/messaging/endpoints.py12
2 files changed, 30 insertions, 6 deletions
diff --git a/python/qpid/selector.py b/python/qpid/selector.py
index ca5946c3f9..ff94091da0 100644
--- a/python/qpid/selector.py
+++ b/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/python/qpid/tests/messaging/endpoints.py b/python/qpid/tests/messaging/endpoints.py
index 62deacd0bd..a82a9e95ed 100644
--- a/python/qpid/tests/messaging/endpoints.py
+++ b/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())