-----Original Message----- From: Python-ideas [mailto:python-ideas- firstname.lastname@example.org] On Behalf Of Guido van Rossum Sent: 29. október 2012 16:35 To: Richard Oudkerk Cc: email@example.com Subject: Re: [Python-ideas] Async API: some code to review
It is a common pattern to have multiple threads/processes trying to accept connections on an single listening socket, so it would be unfortunate to disallow that.
Ah, but that will work -- each thread has its own pollster, event loop and scheduler and collection of tasks. And listening on a socket is a pretty special case anyway -- I imagine we'd build a special API just for that purpose.
I don't think he meant actual "threads" but rather thread in the context of coroutines. in StacklessIO (our custom sockets lib for stackless) multiple tasklets can have an "accept" pending on a socket, so that when multiple connections arrive, wakeup time is minimal.
We have also been careful to allow multiple operations on sockets, from different tasklets, although the same caveats apply as when multiple threads perform operations, i.e. no guarantees about it making any sense. The important bit is that when such things happen, you get some defined result, rather than for example a tasklet being infinitely blocked. Such errors are suprising and hard to debug.