File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 15
15
import os
16
16
import json
17
17
import time
18
+ import socket
18
19
import logging
19
20
import datetime
20
21
import urllib .request
@@ -51,7 +52,7 @@ def _send_http_request(url, data):
51
52
52
53
while resp is None :
53
54
try :
54
- with urllib .request .urlopen (req ) as f :
55
+ with urllib .request .urlopen (req , timeout = 120 ) as f :
55
56
resp = f .read ().decode ('utf-8' )
56
57
# except socket.error as e:
57
58
# if e.errno in connection_errors:
@@ -66,6 +67,9 @@ def _send_http_request(url, data):
66
67
except ConnectionError as e :
67
68
log .warning ('connection problem to %s: %s, trying one more time in 5s' , url , str (e ))
68
69
time .sleep (5 )
70
+ except socket .timeout :
71
+ log .warning ('connection timeout to %s, trying one more time in 5s' , url )
72
+ time .sleep (5 )
69
73
except Exception :
70
74
log .exception ('some problem with connecting to server to %s' , url )
71
75
log .info ('trying one more time in 5s' )
You can’t perform that action at this time.
0 commit comments