Download thread error handling

This commit is contained in:
Peter Šurda 2017-10-22 15:28:30 +02:00
parent 75a6f605c1
commit 4b40d4bce1
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -47,11 +47,17 @@ class DownloadThread(threading.Thread, StoppableThread):
timedOut = now - DownloadThread.requestTimeout timedOut = now - DownloadThread.requestTimeout
# this may take a while, but it needs a consistency so I think it's better to lock a bigger chunk # this may take a while, but it needs a consistency so I think it's better to lock a bigger chunk
with i.objectsNewToMeLock: with i.objectsNewToMeLock:
try:
downloadPending = len(list((k for k, v in i.objectsNewToMe.iteritems() if k in missingObjects and missingObjects[k] > timedOut))) downloadPending = len(list((k for k, v in i.objectsNewToMe.iteritems() if k in missingObjects and missingObjects[k] > timedOut)))
except KeyError:
continue
if downloadPending >= DownloadThread.minPending: if downloadPending >= DownloadThread.minPending:
continue continue
# keys with True values in the dict # keys with True values in the dict
try:
request = list((k for k, v in i.objectsNewToMe.iteritems() if k not in missingObjects or missingObjects[k] < timedOut)) request = list((k for k, v in i.objectsNewToMe.iteritems() if k not in missingObjects or missingObjects[k] < timedOut))
except KeyError:
continue
random.shuffle(request) random.shuffle(request)
if not request: if not request:
continue continue