[Python-ideas] async: feedback on EventLoop API

Guido van Rossum guido at python.org
Tue Dec 18 01:00:55 CET 2012


On Mon, Dec 17, 2012 at 2:11 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Tue, 18 Dec 2012 11:00:35 +1300
> Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>> Guido van Rossum wrote:
>> > (*) Most event loops I've seen use e.g. 30 seconds or 1 hour as
>> > infinity, with the idea that if somehow a race condition added
>> > something to the ready queue just as we went to sleep, and there's no
>> > I/O at all, the system will recover eventually.
>>
>> I don't see how such a race condition can occur in a
>> cooperative multitasking system. There are no true
>> interrupts that can cause something to happen when
>> you're not expecting it. So I'd say let infinity
>> really mean infinity.
>
> Most event loops out there allow you to schedule callbacks from other
> (preemptive, OS-level) threads.

That's what call_soon_threadsafe() is for. But bugs happen (in either
user code or library code). And yes, call_soon_threadsafe() will use a
self-pipe on UNIX. (I hope someone else will write the Windows main
loop.)

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list