how do you implement a reactor without a select?

Michele Simionato michele.simionato at gmail.com
Mon May 7 23:48:29 EDT 2007


On May 8, 4:53 am, a... at mac.com (Alex Martelli) wrote:
> What do you expect from "timers on Linux" that you could not get with a
> simple "sleep for the next N milliseconds"?  A timer (on Linux or
> elsewhere) can jog your process N milliseconds from now, e.g. with a
> SIGALRM or SIGPROF, and you can set one with the setitimer syscall
> (presumably accessible via ctypes, worst case -- I've never used it from
> Python, yet), but how would that help you (compared to plain sleep,
> select, poll, or whatever else best fits your need)?

I hoped there was a library such thay I could register a Python
callable (say
a thunk) and having it called by the linux timer at time t without
blocking
my process. But if a Linux timer will just send to my process an
alarm, I would need to code myself a mechanism waiting for the alarm
and doing the function call. In that case as you say, I would be
better off with a select+timeout or a even with a queue+timeout, which
already do most of the job.

  Michele Simionato




More information about the Python-list mailing list