Connecting Tech Pros Worldwide Help | Site Map

how to Running a particular funtion at a regular interval of time

Newbie
 
Join Date: Feb 2009
Posts: 11
#1: Mar 13 '09
I'm executing two function in a program in a infinite loop.

In that loop i want run a particular a particular function which is out side the function, but that function also runs simultaneously with that function.

when i tried with the threading.Timer(), the function that is to be executed, it throws an exception as cannot start another thread of that function. As that function is already running in the loop.

Can u provide me the solution ASAP.

Thanks in advance......
bvdet's Avatar
Moderator
 
Join Date: Oct 2006
Location: Nashville, TN
Posts: 1,560
#2: Mar 13 '09

re: how to Running a particular funtion at a regular interval of time


I don't know if I can help you, but you would be more likely to receive help if you posted your code.

-BV, Moderator
Newbie
 
Join Date: Feb 2009
Posts: 11
#3: Mar 14 '09

re: how to Running a particular funtion at a regular interval of time


[:)]
I found a way to run it....
anyway thanks...........
bvdet's Avatar
Moderator
 
Join Date: Oct 2006
Location: Nashville, TN
Posts: 1,560
#4: Mar 14 '09

re: how to Running a particular funtion at a regular interval of time


Would you care to share your solution with us in case someone else has this problem?
Newbie
 
Join Date: Feb 2009
Posts: 11
#5: Mar 14 '09

re: how to Running a particular funtion at a regular interval of time


yaa sure....
Expand|Select|Wrap|Line Numbers
  1. import time 
  2. the_time = time.time()
  3. Timer_Counter = 30
  4.  
  5. def sample(request)
  6.     global the_time
  7.     elapsed_time = time.time() - the _time
  8.     if elapsed_time < 0
  9.          do.....something or call a function
  10.          the_time() = time.time()

Here the Sample function runs in infinite loop.
after every 30 seconds the some other code also executes....
bvdet's Avatar
Moderator
 
Join Date: Oct 2006
Location: Nashville, TN
Posts: 1,560
#6: Mar 14 '09

re: how to Running a particular funtion at a regular interval of time


Thank you for sharing. I added code tags around your code. That makes it easier to read and the indentation is preserved.

-BV
Newbie
 
Join Date: Feb 2009
Posts: 11
#7: Mar 14 '09

re: how to Running a particular funtion at a regular interval of time


thank you very much........................
Reply

Tags
timer