As I understand, this won't work:
import msgpack
fd = sock.makefile("rb")
unpacker = msgpack.Unpacker(fd, encoding="utf-8")
packet = unpacker.next()
From the msgepack python implementation, the unpacker will emit this:
fd.read(min(1024**2, max_buffer_size))
```
(ref: https://github.com/msgpack/msgpack-python/blob/master/msgpack/_unpacker.pyx#L323-L326)
This will block forever, as the read will return either at EOF or when the length is reached.
I came up with this solution:
```python
unpacker = msgpack.Unpacker(encoding="utf-8")
# do not worry about timeouts
while True:
buf = sock.recv(1024**2)
unpacker.feed(buf)
try:
packet = unpacker.next()
break
except StopIteration:
continue
```
A real stream process implementation is discussed here:
https://github.com/msgpack/msgpack-python/issues/48