Created
February 18, 2015 17:36
-
-
Save robby-d/636184412acc270bf2ad to your computer and use it in GitHub Desktop.
Sample counterparty API retry script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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