More fixes in objects to be downloaded
This commit is contained in:
parent
bd1aead46e
commit
12205ee7ba
|
@ -121,23 +121,22 @@ class Missing(object):
|
||||||
def pull(self, count=1):
|
def pull(self, count=1):
|
||||||
if count < 1:
|
if count < 1:
|
||||||
raise ValueError("Must be at least one")
|
raise ValueError("Must be at least one")
|
||||||
with self.lock:
|
objectHashes = []
|
||||||
objectHashes = []
|
try:
|
||||||
try:
|
for objectHash in self.hashes.keys():
|
||||||
for objectHash in self.hashes.keys():
|
if self.hashes[objectHash]['requested'] < time.time() - self.frequency:
|
||||||
if self.hashes[objectHash]['requested'] < time.time() - self.frequency:
|
if len(self.hashes[objectHash]['peers']) == 0:
|
||||||
if len(self.hashes[objectHash]['peers']) == 0:
|
self.removeObjectFromCurrentThread(objectHash)
|
||||||
self.removeObjectFromCurrentThread(objectHash)
|
continue
|
||||||
continue
|
if current_thread().peer in self.hashes[objectHash]['peers']:
|
||||||
if current_thread().peer in self.hashes[objectHash]['peers']:
|
objectHashes.append(objectHash)
|
||||||
objectHashes.append(objectHash)
|
self.removeObjectFromCurrentThread(objectHash)
|
||||||
self.removeObjectFromCurrentThread(objectHash)
|
if len(objectHashes) >= count:
|
||||||
if len(objectHashes) >= count:
|
break
|
||||||
break
|
except (RuntimeError, KeyError, ValueError):
|
||||||
except RuntimeError:
|
# the for cycle sometimes breaks if you remove elements
|
||||||
# the for cycle sometimes breaks if you remove elements
|
pass
|
||||||
pass
|
return objectHashes
|
||||||
return objectHashes
|
|
||||||
|
|
||||||
def delete(self, objectHash):
|
def delete(self, objectHash):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
|
Reference in New Issue
Block a user