Browse Source

Обработка timeout для urllib.

В одном из запусков timeout не определился как UrlError
tags/3.4.1.1
Mike Khiretskiy 5 years ago
parent
commit
9933d9cdc4
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      pym/update/variables/update.py

+ 4
- 1
pym/update/variables/update.py View File

@@ -297,11 +297,14 @@ class VariableClUpdateBinhostData(ReadonlyTableVariable):
self.Get('cl_update_binhost_timestamp_path'))
try:
t = time.time()
data = urllib2.urlopen(timestamp_file, timeout=timeout).read().strip()
data = urllib2.urlopen(timestamp_file,
timeout=timeout).read().strip()
if data.isdigit() and t - int(data) < 5 * DAY:
return data, int((time.time() - t)*1000)
except urllib2.URLError as e:
pass
except BaseException as e:
pass
return "", -1

def get(self, hr=False):


Loading…
Cancel
Save