Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Can I set up a timed callback without Tkinter or twisted or something? (http://www.velocityreviews.com/forums/t395245-can-i-set-up-a-timed-callback-without-tkinter-or-twisted-or-something.html)

Hendrik van Rooyen 10-14-2006 03:22 PM

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 "supervisory" 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


hg 10-14-2006 04:06 PM

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 "supervisory" 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
>


http://python.active-venture.com/lib/timer-objects.html

Scott David Daniels 10-14-2006 04:08 PM

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 "supervisory" 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@acm.org

Hendrik van Rooyen 10-15-2006 06:31 AM

Re: Can I set up a timed callback without Tkinter or twistedorsomething?
 
"Scott David Daniels" <scott.daniels@acm.org> wrote:


> 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 "supervisory" 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


Hendrik van Rooyen 10-15-2006 06:33 AM

Re: Can I set up a timed callback without Tkinter or twistedorsomething?
 

"hg" <hg@nospam.com> wrote:


> 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 "supervisory" 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
> >

>
> http://python.active-venture.com/lib/timer-objects.html
>

Thanks - will check it out - Hendrik


skip@pobox.com 10-15-2006 12:24 PM

Re: Can I set up a timed callback without Tkinter or twistedorsomething?
 

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

Have you tried:

import signal
help(signal)

at the interpreter prompt?

Skip

Hendrik van Rooyen 10-17-2006 04:44 AM

Re: Can I set up a timed callback without Tkinter or twistedorsomething?
 

<skip@pobox.com> wrote:

>
> Hendrik> is there not something based on signals? - I seem to recall
> Hendrik> some 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



All times are GMT. The time now is 10:18 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.