Example #1
0
 def totalSize():
     size = 0
     for thread in threadingEnumerate():
         if thread.isAlive() and hasattr(thread, 'downloadQueue'):
             size += thread.downloadQueue.qsize() + len(
                 thread.downloadQueue.pending)
     return size
Example #2
0
 def add(self, objectHash = None):
     with self.lock:
         # add a new object into existing thread lists
         if objectHash:
             if objectHash not in self.hashes:
                 self.hashes[objectHash] = {'created': time.time(), 'sendCount': 0, 'peers': []}
             for thread in threadingEnumerate():
                 if thread.isAlive() and hasattr(thread, 'peer') and \
                     thread.peer not in self.hashes[objectHash]['peers']:
                     self.hashes[objectHash]['peers'].append(thread.peer)
         # add all objects into the current thread
         else:
             for objectHash in self.hashes:
                 if current_thread().peer not in self.hashes[objectHash]['peers']:
                     self.hashes[objectHash]['peers'].append(current_thread().peer)
Example #3
0
 def add(self, objectHash = None):
     with self.lock:
         # add a new object into existing thread lists
         if objectHash:
             if objectHash not in self.hashes:
                 self.hashes[objectHash] = {'created': time.time(), 'sendCount': 0, 'peers': []}
             for thread in threadingEnumerate():
                 if thread.isAlive() and hasattr(thread, 'peer') and \
                     thread.peer not in self.hashes[objectHash]['peers']:
                     self.hashes[objectHash]['peers'].append(thread.peer)
         # add all objects into the current thread
         else:
             for objectHash in self.hashes:
                 if current_thread().peer not in self.hashes[objectHash]['peers']:
                     self.hashes[objectHash]['peers'].append(current_thread().peer)
Example #4
0
 def stop():
     for thread in threadingEnumerate():
         if thread.isAlive() and hasattr(thread, 'downloadQueue'):
             thread.downloadQueue.stopped = True
             with thread.downloadQueue.lock:
                 thread.downloadQueue.pending = {}
Example #5
0
 def stop():
     for thread in threadingEnumerate():
         if thread.isAlive() and hasattr(thread, 'downloadQueue'):
             thread.downloadQueue.stopped = True
             with thread.downloadQueue.lock:
                 thread.downloadQueue.pending = {}
Example #6
0
 def totalSize():
     size = 0
     for thread in threadingEnumerate():
         if thread.isAlive() and hasattr(thread, 'downloadQueue'):
             size += thread.downloadQueue.qsize() + len(thread.downloadQueue.pending)
     return size