equivalent to Tcl 'after' command?

Jeff Epler jepler at unpythonic.net
Thu Apr 22 21:33:26 EDT 2004


> On Thu, 22 Apr 2004 17:42:37 GMT, Mark Harrison <mh at pixar.com>
> wrote:
> > I'm writing some event-driven programs, and I would like
> > to do the equivalent of the Tcl 'after' command, e.g.:
> > 
> > 	after 1000 {puts "one second has elapsed"}
> > 
> > 1.  What's the most canonical way of doing this?
> 
On Thu, Apr 22, 2004 at 11:52:57PM +0100, Alan Gauld wrote:
> I suspect its to start a thread that in turn starts with 
> a sleep command. Not very pretty but approximately the same.

But "doing something in about X ms in a thread" and "doing something in
about X ms from the event loop" are different: the latter basically
frees you from worrying about locking, race conditions, and the rest,
because you know it can't run concurrently with arbitrary other code.

Jeff




More information about the Python-list mailing list