Is it possible to use 'groupby' asynchronously?

Frank Millman frank at chagford.com
Thu Oct 6 08:09:56 EDT 2016


Hi all

I have used itertools.groupby before, and I love it. I used it to process a 
csv file and 'break' on change of a particular field. It worked very well.

Now I want to use it to process a database table. I can select the rows in 
the desired sequence with no problem. However, I am using asyncio, so I am 
reading the rows asynchronously.

My 'reader' class has __aiter__() and __anext__() defined.

If I pass the reader to groupby, I get the error message 'object is not 
iterable'.

Before I spend hours trying to figure it out, can anyone confirm if this is 
doable at all, or is groupby not designed for this.

Thanks

Frank Millman





More information about the Python-list mailing list