More fixes for objects to be downloaded
This commit is contained in:
parent
d04c0e78e4
commit
bd1aead46e
|
@ -86,12 +86,12 @@ class Inventory(collections.MutableMapping):
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class Missing(object):
|
class Missing(object):
|
||||||
frequency = 60
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(self.__class__, self).__init__()
|
super(self.__class__, self).__init__()
|
||||||
self.lock = RLock()
|
self.lock = RLock()
|
||||||
self.hashes = {}
|
self.hashes = {}
|
||||||
self.stopped = False
|
self.stopped = False
|
||||||
|
self.frequency = 60
|
||||||
|
|
||||||
def add(self, objectHash):
|
def add(self, objectHash):
|
||||||
if self.stopped:
|
if self.stopped:
|
||||||
|
@ -113,7 +113,7 @@ class Missing(object):
|
||||||
return
|
return
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
if len(self.hashes[objectHash]['peers']) == 0 and self.hashes[objectHash]['requested'] < time.time() - Missing.frequency:
|
if len(self.hashes[objectHash]['peers']) == 0 and self.hashes[objectHash]['requested'] < time.time() - self.frequency:
|
||||||
self.delete(objectHash)
|
self.delete(objectHash)
|
||||||
else:
|
else:
|
||||||
self.hashes[objectHash]['requested'] = time.time()
|
self.hashes[objectHash]['requested'] = time.time()
|
||||||
|
@ -125,11 +125,15 @@ class Missing(object):
|
||||||
objectHashes = []
|
objectHashes = []
|
||||||
try:
|
try:
|
||||||
for objectHash in self.hashes.keys():
|
for objectHash in self.hashes.keys():
|
||||||
if current_thread().peer in self.hashes[objectHash]['peers'] and self.hashes[objectHash]['requested'] < time.time() - Missing.frequency:
|
if self.hashes[objectHash]['requested'] < time.time() - self.frequency:
|
||||||
objectHashes.append(objectHash)
|
if len(self.hashes[objectHash]['peers']) == 0:
|
||||||
self.removeObjectFromCurrentThread(objectHash)
|
self.removeObjectFromCurrentThread(objectHash)
|
||||||
if len(objectHashes) >= count:
|
continue
|
||||||
break
|
if current_thread().peer in self.hashes[objectHash]['peers']:
|
||||||
|
objectHashes.append(objectHash)
|
||||||
|
self.removeObjectFromCurrentThread(objectHash)
|
||||||
|
if len(objectHashes) >= count:
|
||||||
|
break
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
# the for cycle sometimes breaks if you remove elements
|
# the for cycle sometimes breaks if you remove elements
|
||||||
pass
|
pass
|
||||||
|
|
Reference in New Issue
Block a user