Re: how to call a function for evry 10 secs

2011-07-02 Thread anand jeyahar
> > > Hi All, > > I need to call a function for evry 10 secs > > how can i achieve this in python > > > import time > while True: >time.sleep(10) >function() > Please don't reinvent the wheel... Use the python apscheduler module. http://packages.python.org/APScheduler/#installing-apsche

Re: how to call a function for evry 10 secs

2011-07-01 Thread Rune
>Dennis Lee Bieber: > Timer() is a one-shot; per the OPs requirements even it would need > to be placed within a loop to invoke multiple calls -- so there isn't > much gain in terms of lines of code... And worse, since it calls the > function asynchronously and not sequentially, a delay time

Re: how to call a function for evry 10 secs

2011-07-01 Thread Rune Strand
from threading import Timer def Func_to_call: do_stuff() my_timer = Timer(10, Func_to_call) my_timer.start() -- http://mail.python.org/mailman/listinfo/python-list

Re: how to call a function for evry 10 secs

2011-07-01 Thread Ulrich Eckhardt
Ulrich Eckhardt wrote: > I'll take this to the developers mailinglist and see if they > consider the behaviour a bug. Filed as bug #12459. Uli -- Domino Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list

Re: how to call a function for evry 10 secs

2011-06-30 Thread Ulrich Eckhardt
Dennis Lee Bieber wrote: > And that was a direct cut&paste from a command window; showing it > had slept for some 90 seconds before I killed it. Interesting. Just tried a 2.7.2 on a 32-bit MS Windows with following results: 1. sleep(5 - 2**32) sleeps for a few seconds 2. sleep(-1) sleeps much lo

Re: how to call a function for evry 10 secs

2011-06-30 Thread Ian Kelly
On Thu, Jun 30, 2011 at 11:18 AM, MRAB wrote: >>        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. It gets cast to an unsigned long, so I expect sleep(-1) on Wi

Re: how to call a function for evry 10 secs

2011-06-30 Thread Chris Angelico
On Fri, Jul 1, 2011 at 3:18 AM, MRAB wrote: > 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)? The obvious thing for it to do is to go back in time and resume executing that many se

Re: how to call a function for evry 10 secs

2011-06-30 Thread MRAB
On 30/06/2011 17:42, Dennis Lee Bieber wrote: On Thu, 30 Jun 2011 10:37:34 +0200, Ulrich Eckhardt declaimed the following in gmane.comp.python.general: "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 you

Re: how to call a function for evry 10 secs

2011-06-30 Thread Ulrich Eckhardt
Dennis Lee Bieber wrote: > 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! "time.sleep()" takes a floating point number, so an underflow like for fixed

Re: how to call a function for evry 10 secs

2011-06-30 Thread Laurent Claessens
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! Launch each call in a separate thread. If the calls are independent, this could be a solution.

Re: how to call a function for evry 10 secs

2011-06-29 Thread Max Countryman
Yeah it won't work. Recursion depth will be reached. Steven's suggestion is much better. -- Max Countryman +1-917-971-8472 On Wednesday, June 29, 2011 at 2:05 PM, santosh h s wrote: > how to end ths over a period of time > > On Wed, Jun 29, 2011 at 11:25 PM, Max Countryman (mailto:m...@me.c

Re: how to call a function for evry 10 secs

2011-06-29 Thread Steven D'Aprano
hisan wrote: > Hi All, > I need to call a function for evry 10 secs > how can i achieve this in python import time while True: time.sleep(10) function() -- Steven -- http://mail.python.org/mailman/listinfo/python-list

how to call a function for evry 10 secs

2011-06-29 Thread hisan
Hi All, I need to call a function for evry 10 secs how can i achieve this in python -- http://mail.python.org/mailman/listinfo/python-list