Skip to content

Instantly share code, notes, and snippets.

@robby-d
Created February 18, 2015 17:36
Show Gist options
  • Save robby-d/636184412acc270bf2ad to your computer and use it in GitHub Desktop.
Save robby-d/636184412acc270bf2ad to your computer and use it in GitHub Desktop.
Sample counterparty API retry script
import json
import requests
import time
from requests.auth import HTTPBasicAuth
url = "http://localhost:4000/api/"
headers = {'content-type': 'application/json'}
auth = HTTPBasicAuth('rpc', PASSWORD)
payload = {
"method": "get_running_info",
"params": {},
"jsonrpc": "2.0",
"id": 0,
}
while True:
t_start = time.time()
response = requests.post(url, data=json.dumps(payload), headers=headers, auth=auth)
t_end = time.time()
print("Got code: %s in %s seconds" % (response.status_code, t_end - t_start))
time.sleep(.25)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment