time.sleep(1) sometimes runs for 200 seconds under windows
Peter Hansen
peter at engcorp.com
Thu Feb 23 16:53:49 EST 2006
Paul Probert wrote:
> My app runs in a loop looking for changes in a database, and like a
> good boy I call time.sleep(1) inside the loop. Unfortunately this
> sometimes runs for 200 seconds or so, presumably while my OS is calling
> Bill Gates to tell him what I've been doing. This happens under NT4,
> W2k, and XP. What do people do to fix this? Thanks!
Are you saying that you believe the time.sleep(1) call is actually
blocking for 200 seconds? Or just that your loop (and we can only guess
what it looks like) is the one taking that long?
If the former, try something like putting "print 'before'" and "print
'after'" before and after the sleep, and observe what happens when you
run the program. I'm fairly confident in saying there's no chance
you'll see the "before" sit for 200s before you see the "after" and that
your problem lies elsewhere, not with time.sleep(1).
If the latter, um, obviously we can't help without more info.
-Peter
More information about the Python-list
mailing list