def network_time_out_err or func def try_network self args kwargs for

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def network_time_out_error(func):
def try_network(self, *args, **kwargs):
for i in range(config.MAX_COUNT_NETWORK_ERROR):
try:
return func(self, *args, **kwargs)
except grab.error.GrabTimeoutError:
logger.error('GrabTimeoutError: count try = {}'.format(i))
if i == config.MAX_COUNT_NETWORK_ERROR - 1:
raise
else:
break
return try_network