Public bug reported:
Binary package hint: python2.5-minimal
Ubuntu 7.10
Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32)
Sometimes, time.sleep() in python raises "IOError: [Errno 22] Invalid
argument" in multi-threaded app. This exception is similar to what is
raised when sleep()'s argument is non-positive, but it isn't the case. I
believe that it happens (rarely) when in another thread an exception is
raised (even if it's catched later). It happens both when I call sleep()
directly from my code or indirectly from a standard python library (for
example threading.Condition class uses sleep, and the bug reproduces
with it, too).
Here goes the script with which I reproduce this bug (about two or
threee times in ten runs of the script). With the same script at Debian
3.1, python 2.4.1, I can't reproduce the bug (and I believe that it
really doesn't happen there).
#!/usr/bin/python2.5
import threading, time, random, sys
stopped = False
def do_sleep():
while not stopped:
time.sleep(random.random()/1000 + 0.001)
class MyException(Exception):
pass
def do_raise():
while not stopped:
try:
time.sleep(0.01)
raise MyException
except:
pass
sleepers = [threading.Thread(target = do_sleep) for i in range(100)]
raisers = [threading.Thread(target = do_raise) for i in range(100)]
for s in sleepers: s.start()
for s in raisers: s.start()
for i in range(100):
print ',',
sys.stdout.flush()
time.sleep(1)
stopped = True
for s in sleepers: s.join()
for s in raisers: s.join()
print '.'
** Affects: python2.5 (Ubuntu)
Importance: Undecided
Status: New
--
Python time.sleep() raises exception in multi-threaded app
https://bugs.launchpad.net/bugs/191509
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs