El sábado, 1 de agosto de 2015, 21:15:07 (UTC+2), Marko Rauhamaa escribió: > Javier <jcarm...@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
Great! it works! I could not find a way to send an integer with fixed length, struct.pack/unpack does the job perfectly. Thanks! -- https://mail.python.org/mailman/listinfo/python-list