diff options
author | Inada Naoki <songofacandy@gmail.com> | 2020-12-04 17:23:09 +0900 |
---|---|---|
committer | Inada Naoki <songofacandy@gmail.com> | 2020-12-04 17:52:24 +0900 |
commit | 44bc2bd439808ad7563ef8a558ad6ccfe175a66a (patch) | |
tree | bfca13a3d16320dfda59487002b5c9dc6289db4d /msgpack/fallback.py | |
parent | 8fb709f2e0438862020d8810fa70a81fb5dac7d4 (diff) | |
download | msgpack-python-44bc2bd439808ad7563ef8a558ad6ccfe175a66a.tar.gz |
Update docstring
Diffstat (limited to 'msgpack/fallback.py')
-rw-r--r-- | msgpack/fallback.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/msgpack/fallback.py b/msgpack/fallback.py index 9739d53..0bfa94e 100644 --- a/msgpack/fallback.py +++ b/msgpack/fallback.py @@ -744,7 +744,7 @@ class Packer(object): """ MessagePack Packer - Usage: + Usage:: packer = Packer() astream.write(packer.pack(a)) @@ -784,6 +784,29 @@ class Packer(object): :param str unicode_errors: The error handler for encoding unicode. (default: 'strict') DO NOT USE THIS!! This option is kept for very specific usage. + + Example of streaming deserialize from file-like object:: + + unpacker = Unpacker(file_like) + for o in unpacker: + process(o) + + Example of streaming deserialize from socket:: + + unpacker = Unpacker() + while True: + buf = sock.recv(1024**2) + if not buf: + break + unpacker.feed(buf) + for o in unpacker: + process(o) + + Raises ``ExtraData`` when *packed* contains extra bytes. + Raises ``OutOfData`` when *packed* is incomplete. + Raises ``FormatError`` when *packed* is not valid msgpack. + Raises ``StackError`` when *packed* contains too nested. + Other exceptions can be raised during unpacking. """ def __init__( |