[
https://issues.apache.org/jira/browse/QPID-2294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13872259#comment-13872259
]
Gordon Sim edited comment on QPID-2294 at 1/15/14 5:03 PM:
-----------------------------------------------------------
This is easy to reproduce in any qpid.messaging based application that handles
signals.
Suggested fix:
{noformat}
diff --git a/qpid/python/qpid/compat.py b/qpid/python/qpid/compat.py
index 8b1f4b7..e619f21 100644
--- a/qpid/python/qpid/compat.py
+++ b/qpid/python/qpid/compat.py
@@ -18,6 +18,7 @@
#
import sys
+import errno
try:
set = set
@@ -42,6 +43,7 @@ if tuple(sys.version_info[0:2]) < (2, 4):
return old_select(list(rlist), list(wlist), list(xlist), timeout)
else:
from select import select
+ from select import error as SelectError
class BaseWaiter:
@@ -50,7 +52,13 @@ class BaseWaiter:
def wait(self, timeout=None):
if timeout is not None:
- ready, _, _ = select([self], [], [], timeout)
+ while True:
+ try:
+ ready, _, _ = select([self], [], [], timeout)
+ break
+ except SelectError, e:
+ if not e[0] == errno.EINTR:
+ raise e
else:
ready = True
{noformat}
was (Author: gsim):
This is easy to reproduce in any qpid.messaging based application that handles
signals.
Suggested fix:
{noformat}
diff --git a/qpid/python/qpid/compat.py b/qpid/python/qpid/compat.py
index 8b1f4b7..37c5bed 100644
--- a/qpid/python/qpid/compat.py
+++ b/qpid/python/qpid/compat.py
@@ -42,6 +42,7 @@ if tuple(sys.version_info[0:2]) < (2, 4):
return old_select(list(rlist), list(wlist), list(xlist), timeout)
else:
from select import select
+ from select import error as SelectError
class BaseWaiter:
@@ -50,7 +51,11 @@ class BaseWaiter:
def wait(self, timeout=None):
if timeout is not None:
- ready, _, _ = select([self], [], [], timeout)
+ while True:
+ try:
+ ready, _, _ = select([self], [], [], timeout)
+ break
+ except SelectError: None
else:
ready = True
{noformat}
> The Unix python client can erroneously throw exceptions from select due to
> interrupted system call
> --------------------------------------------------------------------------------------------------
>
> Key: QPID-2294
> URL: https://issues.apache.org/jira/browse/QPID-2294
> Project: Qpid
> Issue Type: Bug
> Components: Python Client
> Affects Versions: 0.6
> Environment: Red Hat Enterprise Linux 5.4
> Reporter: Andrew Stitcher
> Assignee: Rafael H. Schloming
>
> When running autotools "make check"
> You can cause the python_tests to fail in the qpid.tests.messaging section
> (and perhaps elsewhere) by resizing the window that is running the tests.
> You get something like this:
> qpid.tests.messaging.SenderTests.testSendAsyncCapacityUNLIMITED
> ............................ fail
> Error during test:
> Traceback (most recent call last):
> File
> "/home/astitche/bld-working/src/tests/python/commands/qpid-python-test", line
> 307, in run
> phase()
> File
> "/home/astitche/bld-working/src/tests/python/qpid/tests/messaging.py", line
> 796, in testSendAsyncCapacityUNLIMITED
> self.asyncTest(UNLIMITED)
> File
> "/home/astitche/bld-working/src/tests/python/qpid/tests/messaging.py", line
> 777, in asyncTest
> drained = self.drain(self.rcv, timeout=self.delay())
> File
> "/home/astitche/bld-working/src/tests/python/qpid/tests/messaging.py", line
> 84, in drain
> contents.append(rcv.fetch(timeout=timeout).content)
> File "<string>", line 6, in fetch
> File "/home/astitche/bld-working/src/tests/python/qpid/messaging.py",
> line 668, in fetch
> msg = self.session._get(self._pred, timeout=timeout)
> File "<string>", line 6, in _get
> File "/home/astitche/bld-working/src/tests/python/qpid/messaging.py",
> line 360, in _get
> timeout):
> File "/home/astitche/bld-working/src/tests/python/qpid/messaging.py",
> line 294, in _ewait
> result = self.connection._ewait(lambda: self.error or predicate(),
> timeout, exc)
> File "/home/astitche/bld-working/src/tests/python/qpid/messaging.py",
> line 142, in _ewait
> result = self._wait(lambda: self.error or predicate(), timeout)
> File "/home/astitche/bld-working/src/tests/python/qpid/messaging.py",
> line 131, in _wait
> return self._waiter.wait(predicate, timeout=timeout)
> File "/home/astitche/bld-working/src/tests/python/qpid/concurrency.py",
> line 59, in wait
> self.condition.wait(timeout - passed)
> File "/home/astitche/bld-working/src/tests/python/qpid/concurrency.py",
> line 96, in wait
> sw.wait(timeout)
> File "/home/astitche/bld-working/src/tests/python/qpid/compat.py", line
> 53, in wait
> ready, _, _ = select([self], [], [], timeout)
> error: (4, 'Interrupted system call')
> The cause is that python is receiving the SIGWINCH signal from the window
> size change and this is interrupting the select system call. The exception
> that is being thrown by select is not being caught.
> This needs to be fixed as interrupted system calls are a fact of life when
> running on Unix - you could argue that the python run time should just
> restart the select, but it isn't doing that here.
> Note that allowing for interrupted system calls screws up the timeout
> calculation. As you'll need to figure out how much of the wait is left and
> then wait for less time when restarting the system call.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]