Evaluating a Function After X Seconds: Python Equivalent to JavaScript's SetTimeout() Function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ycoci0@gmail.com

    #1

    Evaluating a Function After X Seconds: Python Equivalent to JavaScript's SetTimeout() Function

    Hi all,

    Not exactly new to Python, just have not programmed a time dependent
    function using it before.

    I imagine that many of you may also program some JavaScript and may be
    familiar with JavaScript's SetTimeout( expression, after time interval
    in milliseconds) function. Does Python have an equivalent to this?

    A SetTimeout-like Python function would be ideal for my application.


    Best,

    Y-coci

  • KenAggie

    #2
    Re: Evaluating a Function After X Seconds: Python Equivalent to JavaScript's SetTimeout() Function

    Yea -- the "sched" class is exactly what you need. Just import sched
    and then use it to schedule a function call in the future, either using
    relative time or an absolute time. The python help file tells you how
    in detail.
    - Ken

    ycoci0@gmail.co m wrote:[color=blue]
    > Hi all,
    >
    > Not exactly new to Python, just have not programmed a time dependent
    > function using it before.
    >
    > I imagine that many of you may also program some JavaScript and may be
    > familiar with JavaScript's SetTimeout( expression, after time interval
    > in milliseconds) function. Does Python have an equivalent to this?
    >
    > A SetTimeout-like Python function would be ideal for my application.
    >
    >
    > Best,
    >
    > Y-coci[/color]

    Comment

    • Diez B. Roggisch

      #3
      Re: Evaluating a Function After X Seconds: Python Equivalent to JavaScript'sSet Timeout() Function

      Dennis Lee Bieber schrieb:[color=blue]
      > I don't know? How does "SetTimeout " actually behave? Asynchronously?
      > Synchronously? That is... would[/color]

      The former. It is the poor-mans threading of JavaScript so to speak.

      Diez

      Comment

      Working...