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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neeru29
    New Member
    • Feb 2009
    • 21

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

    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
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    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

    Comment

    • neeru29
      New Member
      • Feb 2009
      • 21

      #3
      [:)]
      I found a way to run it....
      anyway thanks......... ..

      Comment

      • bvdet
        Recognized Expert Specialist
        • Oct 2006
        • 2851

        #4
        Would you care to share your solution with us in case someone else has this problem?

        Comment

        • neeru29
          New Member
          • Feb 2009
          • 21

          #5
          yaa sure....
          Code:
          import time 
          the_time = time.time()
          Timer_Counter = 30
          
          def sample(request)
              global the_time
              elapsed_time = time.time() - the _time
              if elapsed_time < 0
                   do.....something or call a function
                   the_time() = time.time()

          Here the Sample function runs in infinite loop.
          after every 30 seconds the some other code also executes....
          Last edited by bvdet; Mar 14 '09, 02:51 PM. Reason: Add code tags

          Comment

          • bvdet
            Recognized Expert Specialist
            • Oct 2006
            • 2851

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

            -BV

            Comment

            • neeru29
              New Member
              • Feb 2009
              • 21

              #7
              thank you very much........... .............

              Comment

              Working...