Can I set up a timed callback without Tkinter or twisted or something?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hendrik van Rooyen

    #1

    Can I set up a timed callback without Tkinter or twisted or something?

    Hi,

    I want to do the equivalent of the after thingy in tkinter - setting up in
    effect a timed call back.

    My use case is as a "supervisor y" timer - I want to set up an alarm, which I
    want to cancel if the expected occurrence occurs - but its not a GUI app.

    My googling gets a lot of stuff pointing to optparse...

    Does the standard lib have anything like this?

    - Hendrik

  • Scott David Daniels

    #2
    Re: Can I set up a timed callback without Tkinter or twisted or something?

    Hendrik van Rooyen wrote:
    I want to do the equivalent of the after thingy in tkinter - setting up in
    effect a timed call back.
    >
    My use case is as a "supervisor y" timer - I want to set up an alarm, which I
    want to cancel if the expected occurrence occurs - but its not a GUI app.
    Use a thread that uses something like:
    def action():
    sleep(50)
    if not canceled:
    callback(foo)
    as its action.

    The callback ill be in another thread, but .... Look up threading for
    more details.


    --Scott David Daniels
    scott.daniels@a cm.org

    Comment

    • hg

      #3
      Re: Can I set up a timed callback without Tkinter or twisted or something?

      Hendrik van Rooyen wrote:
      Hi,
      >
      I want to do the equivalent of the after thingy in tkinter - setting up in
      effect a timed call back.
      >
      My use case is as a "supervisor y" timer - I want to set up an alarm, which I
      want to cancel if the expected occurrence occurs - but its not a GUI app.
      >
      My googling gets a lot of stuff pointing to optparse...
      >
      Does the standard lib have anything like this?
      >
      - Hendrik
      >

      Comment

      • Hendrik van Rooyen

        #4
        Re: Can I set up a timed callback without Tkinter or twistedorsometh ing?

        "Scott David Daniels" <scott.daniels@ acm.orgwrote:

        Hendrik van Rooyen wrote:
        I want to do the equivalent of the after thingy in tkinter - setting up in
        effect a timed call back.

        My use case is as a "supervisor y" timer - I want to set up an alarm, which I
        want to cancel if the expected occurrence occurs - but its not a GUI app.
        >
        Use a thread that uses something like:
        def action():
        sleep(50)
        if not canceled:
        callback(foo)
        as its action.
        >
        The callback ill be in another thread, but .... Look up threading for
        more details.
        Thanks - I was hoping that I did not have to do it myself - the Tkinter thingy
        works nicely - I was hoping that the interpreter could handle something like
        this... What I don't like too much about the sleep based solution is that yer
        blind and deaf while sleeping - at least in that thread - and I am trying for
        fairly fine grained timing resolution...

        is there not something based on signals? - I seem to recall some such thing
        here in another thread.. ( I am running Linux)

        -Hendrik

        Comment

        • Hendrik van Rooyen

          #5
          Re: Can I set up a timed callback without Tkinter or twistedorsometh ing?


          "hg" <hg@nospam.comw rote:

          Hendrik van Rooyen wrote:
          Hi,

          I want to do the equivalent of the after thingy in tkinter - setting up in
          effect a timed call back.

          My use case is as a "supervisor y" timer - I want to set up an alarm, which I
          want to cancel if the expected occurrence occurs - but its not a GUI app.

          My googling gets a lot of stuff pointing to optparse...

          Does the standard lib have anything like this?

          - Hendrik
          >

          >
          Thanks - will check it out - Hendrik

          Comment

          • skip@pobox.com

            #6
            Re: Can I set up a timed callback without Tkinter or twistedorsometh ing?


            Hendrikis there not something based on signals? - I seem to recall
            Hendriksome such thing here in another thread.. ( I am running Linux)

            Have you tried:

            import signal
            help(signal)

            at the interpreter prompt?

            Skip

            Comment

            • Hendrik van Rooyen

              #7
              Re: Can I set up a timed callback without Tkinter or twistedorsometh ing?


              <skip@pobox.com wrote:
              >
              Hendrikis there not something based on signals? - I seem to recall
              Hendriksome such thing here in another thread.. ( I am running Linux)
              >
              Have you tried:
              >
              import signal
              help(signal)
              >
              at the interpreter prompt?
              >
              Skip
              *blush* - actually, no - I was looking for signals...

              - Hendrik

              Comment

              Working...