daggaz / json-stream

Simple streaming JSON parser and encoder.
MIT License
123 stars 18 forks source link

Support for asyncio ? #54

Open skrawani opened 1 year ago

skrawani commented 1 year ago

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.

daggaz commented 1 year ago

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

pmeier commented 9 months ago

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.