Send data to asyncio coroutine
Marko Rauhamaa
marko at pacujo.net
Sat Aug 1 15:14:54 EDT 2015
Javier <jcarmena at gmail.com>:
> My intention now is to use the asyncio.StreamReader passed as argument
> to the asyncio.start_server callback to read objects serialized with
> pickle. The problems are that pickle cant read from it (because dont
> yield from the full stack) and that I don't know the exact length of
> each serialized object, so I can't extract data manually.
>
> Knows anybody the steps to follow?
You probably need to frame your pickled encoding. A simple thing would
be to use struct.pack/unpack to encode the length of the pickle encoding
in front of the pickle encoding. When decoding, you first read out the
length, then the pickle encoding, and finally you unpickle the payload.
Marko
More information about the Python-list
mailing list