how do I read a series of pickled objects from a socket?
Ryan Grow
ryangrow at yahoo.com
Tue Nov 16 15:55:06 EST 2004
Hi,
I am trying to figure out the correct and most
reliable way to read a series of pickled objects from
a socket.
I've found examples that do something like this:
while 1:
data = conn.recv(500)
obj = pickle.loads(data)
# do stuff with object
I don't think the above example would work for my
application. The above example might work if the
server never expects to get more than one object on
the socket at a time.
The server I'm writing will get a series of objects so
it will need to know where each pickled object ends in
the stream so it knows where to start reading the next
object from.
Is there a correct way to identify the terminator of a
pickled object? Is there a standard and correct way
for the pickle module to easily read pickled objects
from a socket?
Thanks,
Ryan
__________________________________
Do you Yahoo!?
Meet the all-new My Yahoo! - Try it today!
http://my.yahoo.com
More information about the Python-list
mailing list