Skip to content

Instantly share code, notes, and snippets.

@berg
Last active December 13, 2015 21:48
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berg/4979594 to your computer and use it in GitHub Desktop.
Save berg/4979594 to your computer and use it in GitHub Desktop.
Dump an App.net stream to the console. Useful for debugging.
import sys
import time
import json
import requests
endpoint = sys.argv[1]
while True:
r = requests.get(endpoint, stream=True, timeout=600)
for line in r.iter_lines(chunk_size=1):
if line:
blob = json.loads(line)
print '--------', int(time.time()), '->'
print json.dumps(blob, sort_keys=True, indent=2)
print ''
print ''
print 'sleeping before reconnect'
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment