>
> Hi there,

For a pet projet of mine (https://github.com/julienpalard/theodoreserver) I 
encontered a problem:

I was having two asynchronous iterables (easily iterables via a simple 
"async for ..."), without "theodore" knowledge you can simply imagine 
listening for events from different sources.

So my need is what is solved by "select", "poll", "epoll", "kqueue", 
"libevent" on sockets, I need to listen from multiple sources and be 
notified when one has data.

So I wrote an 
"zip": https://github.com/JulienPalard/TheodoreServer/blob/master/asynczip.py 
which two modes, one named "SOON", behaving more like select, and one 
"PAIRED" behaving more like "zip".

Given n asynchronous iterables, you can iterate over them using :


 async for resuts in asynczip.AsyncZip(*iterables) it's really like a 
"asyncio.wait" 
but for an iterable, with `wait`'s flag `FIRST_COMPLETED` being my "SOON" 
flag, and `wait` flag "ALL_COMPLETED" being my "PAIRED" flag (should I 
rename mines ?) Question is: Am I walking the wrong way and is there a 
simple way to do it I completly missed ? Or is my tool really usefull and 
should be shared ? I'm too young in asyncio to juge that, so I'll listen to 
you ! Bests,

-- 
Julien Palard

Reply via email to