File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 4040 retry )
4141import urllib .request
4242import urllib .parse
43+ import urllib .error
4344import json
4445import subprocess
4546from collections import namedtuple
@@ -57,10 +58,12 @@ def http_sql_query(sql_query):
5758 url = (
5859 f'http://{ host } :{ port } /exec?' +
5960 urllib .parse .urlencode ({'query' : sql_query }))
60- resp = urllib .request .urlopen (url , timeout = 0.2 )
61- if resp .status != 200 :
62- raise RuntimeError (f'Error response { resp .status } from { sql_query !r} ' )
63- buf = resp .read ()
61+ buf = None
62+ try :
63+ resp = urllib .request .urlopen (url , timeout = 0.2 )
64+ buf = resp .read ()
65+ except urllib .error .HTTPError as http_error :
66+ buf = http_error .read ()
6467 try :
6568 data = json .loads (buf )
6669 except json .JSONDecodeError as jde :
You can’t perform that action at this time.
0 commit comments