better scheduler with correct sleep times

sokol tvrtko.sokolovski at gmail.com
Thu Oct 23 05:42:26 EDT 2008


On Oct 22, 2:28 am, greg <g... at cosc.canterbury.ac.nz> wrote:
> sokol wrote:
> > Also, the
> > scheduler runs inside a loop. How do you suppose to
> > run other code while the loop is executing?
>
> The sleep function could be doing a select with a
> timeout on some other source of events, such as a
> socket or a gui input event stream. One possible
> response to such an event is to schedule another
> event. There's not so much need for that nowadays,
> since most gui libraries provide a way of scheduling
> timed events as part of their built-in event loop,
> but you might want to use something like this in
> a server that deals with network connections.
>
> Another possible use is discrete-event simulation,
> where the "sleep" function doesn't physically sleep
> but just advances a simulated time, and all events
> (other than the first one that starts everything off)
> are scheduled by callbacks for other events.
>
> So while its uses are rather specialized, I wouldn't
> say it's useless. The main problem is that its nature
> needs to be much more clearly spelled out in the
> docs -- it's something of an attractive nuisance the
> way it is.
>
> --
> Greg

I see. The delayfunc is user defined function so it
doesn't have to sleep at all. If you are creative
enough, you can use this scheduler in many ways.

--
Tvrtko



More information about the Python-list mailing list