D
Derek Fountain
Does Python have a timer mechanism? i.e. an "after 500 milliseconds, run
this bit of code" sort of thing?
this bit of code" sort of thing?
http://www.python.org/Doc/lib/module-sched.htmlDerek said:Does Python have a timer mechanism? i.e. an "after 500 milliseconds, run
this bit of code" sort of thing?
Noen said:
Does Python have a timer mechanism? i.e. an "after 500 milliseconds, run
this bit of code" sort of thing?
Dave said:why not just use the time.sleep() function ?
Because that stops the thread. I want things to continue, and then be
interrupted in order to execute a bit of code. Tcl has the 'after' command:
after 5000 { set disabled 0 }
The script carries on, and after 5 seconds whatever is being done gets
interrupted in order to run a bit of script - in this case set a variable
turning off a disablement of some sort.
Alan said:[Derek Fountain]Does Python have a timer mechanism? i.e. an "after 500 milliseconds, run
this bit of code" sort of thing?
Like this?
http://www.python.org/doc/current/lib/timer-objects.html
Does Python have a timer mechanism? i.e. an "after 500 milliseconds, run
this bit of code" sort of thing?
Because that stops the thread.
.Wow, that must make your scripts so much more interesting to debug
This thread is really about asynchronous or concurrent
processing,
I claim, and I further claim we really don't
have *any* satisfying model for coding those.
Threading
is a quagmire (everyone agree?),
and our guild has demonstrated only marginally more
reliability in working with,
say, co-routines, chords, continuations, and so on. For
my money, the event-oriented model behind the [after]
above is at least as robust as any other.
Among other frailties, I hold a grudge against the aca-
demic world that it hasn't shown more leadership in this
matter.
I'll summarize: validation of event-oriented designs
implemented with [after] and similar mechanisms, is at
worst no more difficult than validation of the corre-
sponding thread-based designs. Concurrency is hard to
get right, at least with our current understanding.
This thread is really about asynchronous or concurrent
processing,
I claim, and I further claim we really don't
have *any* satisfying model for coding those.
Threading
is a quagmire (everyone agree?),
and our guild has demonstrated only marginally more
reliability in working with,
say, co-routines, chords, continuations, and so on. For
my money, the event-oriented model behind the [after]
above is at least as robust as any other.
Among other frailties, I hold a grudge against the aca-
demic world that it hasn't shown more leadership in this
matter.
I'll summarize: validation of event-oriented designs
implemented with [after] and similar mechanisms, is at
worst no more difficult than validation of the corre-
sponding thread-based designs. Concurrency is hard to
get right, at least with our current understanding.
This is mostly a "me, too" follow-up. I decided[Cameron Laird]This thread is really about asynchronous or concurrent
processing,
I really don't have time to post to the level of detail I would like,
but I had to put forward a couple of thoughts.
that Twisted et al. don't feel abused. I am VERYI think you might get some disagreement from the Twisted, Medusa and
ZServer people. And possibly see a slanging match erupt on whose
design is best....
Worth repeating.My €0,02: Generators (and, by extension, coroutines) will be python's
greatest advance in simplifying writing event-based server
architectures: resumable functions are a honking great idea.
Because that stops the thread. I want things to continue, and then be
interrupted in order to execute a bit of code. Tcl has the 'after' command:
Wow, that must make your scripts so much more interesting to debug
I take this question rather seriously, as it turns out.
Scripts that are "easy to debug" make for an apt focus.
This thread is really about asynchronous or concurrent
processing, I claim, and I further claim we really don't
have *any* satisfying model for coding those. Threading
is a quagmire (everyone agree?), and our guild has demon-
strated only marginally more reliability in working with,
say, co-routines, chords, continuations, and so on. For
my money, the event-oriented model behind the [after]
above is at least as robust as any other.
No, I wrote something that I consider true. I'd consider that after
command to be on a par with Fortran's(?) COME FROM statement in terms
of being able to create subtle bugs.
my money, the event-oriented model behind the [after]
above is at least as robust as any other.
Yes, that's what I said - only with fewer words
And the patchy support for SSL in asynch frameworks is another
fundamental problem.
Another point in favour of threads: On a multi-processor box, the
thread abstraction generally "automagically" gives you free migration
to other processors. You (generally) don't have to change a line of
your code: the underlying [OS|VM] takes care of it.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.