Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

interrupted system call with processing queue

We suddenly started see "Interrupted system call" on Queue operations like this:

Exception in thread Thread-2:
Traceback (most recent call last):
[ . . . ]
   result = self.pager.results.get(True, self.WAIT_SECONDS)
 File "/usr/lib/python2.5/site-packages/processing-0.52-py2.5-linux-x86_64.egg/processing/queue.py", line 128, in get
   if not self._poll(block and (deadline-time.time()) or 0.0):
IOError: [Errno 4] Interrupted system call

This is a Fedora 10 / Python 2.5 machine that recently had a security update. Prior to that our software had run for about a year without incident, now it is crashing daily.

Is it correct/necessary to catch this exception and retry the Queue operation?

We don't have any signal handlers that we set, but this is a Tkinter app maybe it sets some. Is it safe to clear the SIGINT handler, would that solve the problem? Thanks.

like image 992
Philip Avatar asked Feb 10 '11 00:02

Philip


1 Answers

Based on this thread on comp.lang.python and this reply from Dan Stromberg I wrote a RetryQueue which is a drop-in replacement for Queue and which does the job for us:

from multiprocessing.queues import Queue
import errno

def retry_on_eintr(function, *args, **kw):
    while True:
        try:
            return function(*args, **kw)
        except IOError, e:            
            if e.errno == errno.EINTR:
                continue
            else:
                raise    

class RetryQueue(Queue):
    """Queue which will retry if interrupted with EINTR."""
    def get(self, block=True, timeout=None):
        return retry_on_eintr(Queue.get, self, block, timeout)
like image 58
Philip Avatar answered Sep 20 '22 02:09

Philip