json-stream icon indicating copy to clipboard operation
json-stream copied to clipboard

Support for asyncio ?

Open skrawani opened this issue 1 year ago • 2 comments

I noticed that there is no mention of asyncio support. Are there any plans to support asyncio in the future? Currently, when async generators are used, it throws a TypeError: 'async_generator' object is not an iterator.

skrawani avatar Oct 31 '23 14:10 skrawani

It's something I've considered adding, but I've no immediate plans

daggaz avatar Oct 31 '23 16:10 daggaz

Just adding a real-world use case: the generative models from Google AI return a JSON stream. However, since json-stream does not support async iterators, I need to make a sync API call. And this has to be done on a thread to avoid blocking the main thread with mostly just waiting for the API to respond.

Since there is workaround, I can still use json-stream here, but it is somewhat inconvenient.

pmeier avatar Jan 31 '24 09:01 pmeier