From 0b1d6f536624d94289ec7740afba9f1a6d9cee14 Mon Sep 17 00:00:00 2001 From: stoffu Date: Wed, 12 Sep 2018 18:27:08 +0900 Subject: [PATCH] getdata: handle RequestException in getblock --- getdata.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/getdata.py b/getdata.py index 76bae9a..48f3fa3 100755 --- a/getdata.py +++ b/getdata.py @@ -42,6 +42,7 @@ from test_framework.daemon import Daemon import sys import datetime import json +import requests class GetData(): def run(self, port, height_window_index): @@ -55,7 +56,13 @@ class GetData(): assert start_height < end_height print('var chartData_%d = [' % height_window_index) for i in range(start_height, end_height): - res_blk = daemon.getblock(i) + while True: + try: + res_blk = daemon.getblock(i) + break + except requests.exceptions.RequestException as e: + continue + block_header = res_blk['block_header'] timestamp = block_header['timestamp']