[Python-Dev] Non-blocking (asynchronous) timer without thread?

Mike Klaas mike.klaas at gmail.com
Sat Dec 23 06:50:09 CET 2006


On 12/22/06, Evgeniy Khramtsov <xramtsov at gmail.com> wrote:
> The question to python core developers:
> Is there any plans to implement non-blocking timer like a
> threading.Timer() but without thread?
> Some interpreted languages (like Tcl or Erlang) have such functionality,
> so I think it would be a great
> feature in Python :)
>
> The main goal is to prevent threads overhead and problems with race
> conditions and deadlocks.

I'm not sure how having python execute code at an arbitrary time would
_reduce_ race conditions and/or deadlocks.  And if you want to make it
safe by executing code that shares no variables or resources, then it
is no less safe to use threads, due to the GIL.

If you can write you application in an event-driven way, Twisted might
be able to do what you are looking for.

cheers,
-Mike


More information about the Python-Dev mailing list