Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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 = {}
Exemplo n.º 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 = {}
Exemplo n.º 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