Skip to content

Instantly share code, notes, and snippets.

@zackdever
Last active August 29, 2015 14:06
Show Gist options
  • Save zackdever/cabb8202830b4da7f8f6 to your computer and use it in GitHub Desktop.
Save zackdever/cabb8202830b4da7f8f6 to your computer and use it in GitHub Desktop.
unpack msgpack from stdin and print until stopped
#!/usr/bin/env python
import msgpack
import sys
try:
while True:
line = sys.stdin.readline().strip('\n')
try:
print msgpack.unpackb(line)
except (TypeError, ValueError, msgpack.exceptions.UnpackValueError,
msgpack.exceptions.ExtraData):
print line
except KeyboardInterrupt:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment