[Python-ideas] Tulip patches

Guido van Rossum guido at python.org
Fri Dec 21 18:30:46 CET 2012


On Fri, Dec 21, 2012 at 7:57 AM, Guido van Rossum <guido at python.org> wrote:
> On Fri, Dec 21, 2012 at 6:31 AM, Geert Jansen <geertj at gmail.com> wrote:
>> Please find attached 4 patches:
>>
>> 0001-run-fd-callbacks.patch
>>
>> This patch will run callbacks for readers and writers in the same loop
>> iteration as when the fd got ready. Copying from my previous email,
>> this is to support the following idiom:
>>
>>     # handle_read() sets the "ready" flag
>>     loop.add_reader(fd, handle_read)
>>     while not ready:
>>         loop.run_once()
>>
>> The patch currently dispatches callbacks twice in each iteration, once
>> before blocking and once after. I tried to dispatch only once after
>> blocking, but this made the SSL transport test hang. The reason is
>> that the create_transport task is scheduled with call_soon(), and only
>> when the task first runs, a file descriptor is added. So unless you
>> dispatch before blocking, this task will never get started.
>
> Interesting. Go ahead and submit.

Whoa! I just figured out the problem. You don't have to run the ready
queue twice. You just have to set the poll timeout to 0 if there's
anything in the ready queue. Please send me an updated patch before
submitting.

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



More information about the Python-ideas mailing list