H
hisan
Hi All,
I need to call a function for evry 10 secs
how can i achieve this in python
I need to call a function for evry 10 secs
how can i achieve this in python
hisan said:Hi All,
I need to call a function for evry 10 secs
how can i achieve this in python
Hi All,
I need to call a function for evry 10 secs
how can i achieve this in python
But if the function itself runs for longer than 10 seconds, there
will be a major problem, as the sleep apparently takes the argument as
unsigned, and a negative number is a very big sleep!
Dennis said:But if the function itself runs for longer than 10 seconds, there
will be a major problem, as the sleep apparently takes the argument as
unsigned, and a negative number is a very big sleep!
WinXP, Python 2.5.<something>"time.sleep()" takes a floating point number, so an underflow like for
fixed-size integers in C shouldn't happen. What puzzles me here is your use
of "apparently", because here a negative value actually raises an "IOError:
[Errno 22] Invalid argument" when I call "sleep(-1)".
The system I'm on is a Debian GNU/Linux system running on some x86 hardware,
for the record, and I'm using Python 2.6.6.
Looks like it hasn't changed even in WinXP, Python 3.2.WinXP, Python 2.5.<something>"time.sleep()" takes a floating point number, so an underflow like for
fixed-size integers in C shouldn't happen. What puzzles me here is your use
of "apparently", because here a negative value actually raises an "IOError:
[Errno 22] Invalid argument" when I call "sleep(-1)".
The system I'm on is a Debian GNU/Linux system running on some x86 hardware,
for the record, and I'm using Python 2.6.6.
And that was a direct cut&paste from a command window; showing it
had slept for some 90 seconds before I killed it.
Looks like it hasn't changed even in WinXP, Python 3.2.
Is IOError what you'd expect, anyway?
What should it do in Python 3.2? Exception or max(seconds, 0)?
Looks like it hasn't changed even in WinXP, Python 3.2.
Is IOError what you'd expect, anyway?
What should it do in Python 3.2? Exception or max(seconds, 0)?
Dennis said:And that was a direct cut&paste from a command window; showing it
had slept for some 90 seconds before I killed it.
"RuntimeError" or "OSError" would seem to be better than "IOError";So this seems to confirm that it's a 32-bit underflow while preparing the
argument for win32's Sleep() function.
That said, an "IOError" is a bit better but still leaves room for
improvement. I'll take this to the developers mailinglist and see if they
consider the behaviour a bug. At the very least the docs are bad, I would
say.
Ulrich said:I'll take this to the developers mailinglist and see if they
consider the behaviour a bug.
from threading import Timer
def Func_to_call:
do_stuff()
my_timer = Timer(10, Func_to_call)
my_timer.start()
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.