msgpack/msgpack-python

[feature] better streaming unpacker

07pepa opened this issue · 1 comments

i propose to be able feed unpacker with iterator / async iterator
its better when data comes over network and chunking may fall into middle of msgpack untill iterator is exhausted there is chance more will come ( i looked into code and this ) but you do not want to buffer anything and just consume as it comes

and async iteration would be also nice
something like this

async def generate()
     while True:
         yield b"some bytes"
unpacker = msgpack.Unpacker(aiter=generate())

async for unpacked in unpacker:
    print(unpacked)

unpacker.feed() can be used with async code. I don't want to add complex interface.