[Python-ideas] yield from multiple iterables (was Re: The async API of the future: yield-from)
Guido van Rossum
guido at python.org
Mon Oct 22 06:10:57 CEST 2012
On Sun, Oct 21, 2012 at 6:18 PM, Eric V. Smith <eric at trueblade.com> wrote:
> On 10/21/2012 8:23 PM, Guido van Rossum wrote:
>> I don't see it that way. Any time you acquire a lock, you may be
>> blocked for a long time. In a typical event loop that's an absolute
>> no-no. Typically, to wait for another thread, you give the other
>> thread a callback that adds a new event for *this* thread.
>> Now, it's possible that in Windows, when using IOCP, the philosophy is
>> different -- I think I've read in
>> http://msdn.microsoft.com/en-us/library/aa365198%28VS.85%29.aspx that
>> there can be multiple threads reading events from a single queue.
> Correct. The typical usage of an IOCP is that you create as many threads
> as you have CPUs (or cores, or execution units, or whatever the kids
> call them these days), then they can all wait on the same IOCP. So if
> you have, say 4 CPUs so 4 threads, they can all be woken up to do useful
> work if the IOCP has work items for them.
So what's the typical way to do locking in such a system? Waiting for
a lock seems bad; and you can't assume that no other callbacks may run
while you are running. What synchronization primitives are typically
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas