[Python-ideas] Async API: some code to review

Glyph glyph at twistedmatrix.com
Wed Oct 31 11:20:29 CET 2012

On Oct 29, 2012, at 5:25 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

> Andrew Svetlov wrote:
>> 0MQ socket has no file descriptor at all, it's just pointer to some
>> unspecified structure.
>> So 0MQ has own *poll* function which can process that sockets as well
>> as file descriptors.
> Aaargh... yet another event loop that wants to rule
> the world. This is not good.

As a wise man once said, "everybody wants to rule the world".

All event loops have their own run() API, and expect to be on top of everything, driving the loop.  This is one of the central principles of Twisted's design; by not attempting to directly take control of any loop, and providing a high-level wrapper around run, and an API that would accommodate every wacky wrapper around poll and select and kqueue and GetQueuedCompletionStatus, we could be a single loop that everything can use as an API and get the advantages of whatever event driven thing is popular this week.

You can't accomplish this by trying to force other loops to play by your rules; rather, accommodate and pave over their peculiarities and it'll be your API that their users actually write to.

(In the land of Mordor, where the shadows lie.)


More information about the Python-ideas mailing list