472,121 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,121 software developers and data experts.

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

21
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......
Mar 13 '09 #1
6 3446
bvdet
2,851 Expert Mod 2GB
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
Mar 13 '09 #2
neeru29
21
[:)]
I found a way to run it....
anyway thanks...........
Mar 14 '09 #3
bvdet
2,851 Expert Mod 2GB
Would you care to share your solution with us in case someone else has this problem?
Mar 14 '09 #4
neeru29
21
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....
Mar 14 '09 #5
bvdet
2,851 Expert Mod 2GB
Thank you for sharing. I added code tags around your code. That makes it easier to read and the indentation is preserved.

-BV
Mar 14 '09 #6
neeru29
21
thank you very much........................
Mar 14 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Todd | last post: by
14 posts views Thread by William LaMartin | last post: by
4 posts views Thread by tshad | last post: by
1 post views Thread by daniel_xi | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.