[Python-Dev] IOError errno=514 in time.sleep(1)

Sean Reifschneider jafo at tummy.com
Thu Jan 11 00:30:28 CET 2007


I've been tracking down an issue with some code sporadically raising
IOError with errno=514 on "time.sleep(1)".  time.sleep() is implemented
with the select() system call, and on Linux this is sporadically returning
errno=514 (ERESTARTNOHAND).

This is on 2.6.9, though I've heard reports of it happening through 2.6.17,
and my review of the code indicates that 2.6.19.1 (the latest kernel) is
probably also going to act the same.

Now, the header file where ERESTARTNOHAND is defined says that user-space
should never see this errno.  Clearly, that's not as true as it could be.
I'm going to ask the LKML for more information about whether this should
make it to user-space, but thought I'd bring it up here as well.

Some options we have:

   Do nothing.  (I like this one :-)

   Catch and ignore 514.  (Only on Linux?  Far-reaching implications, I
   don't like this one).

   Use the libc sleep() call for integer time.sleep() values?  No guarantee
   that libc sleep() doesn't use select, though I've seen indications that
   it might use alarm.  I haven't looked at the libc source.

   Try to make time.sleep() smarter in the face of errnos.  Maybe try the
   sleep multiple times, check time.time() before and after the sleep to do
   multiple sleeps.  Could possibly even fail over to using /dev/rtc if
   select fails?

In general I'm reluctant to suggest a Python fix to this, but it's fairly
unexpected for time.sleep() to raise an exception...

Thoughts?

Sean
-- 
 I think the net needs some Viagra today.  It's just not performing...
                 -- Mike Loseke, 2000
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability



More information about the Python-Dev mailing list