コード例 #1
0
ファイル: inventory.py プロジェクト: RZZT/taskhive-core
 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
コード例 #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)
コード例 #3
0
ファイル: inventory.py プロジェクト: Bitmessage/PyBitmessage
 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)
コード例 #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 = {}
コード例 #5
0
ファイル: inventory.py プロジェクト: Bitmessage/PyBitmessage
 def stop():
     for thread in threadingEnumerate():
         if thread.isAlive() and hasattr(thread, 'downloadQueue'):
             thread.downloadQueue.stopped = True
             with thread.downloadQueue.lock:
                 thread.downloadQueue.pending = {}
コード例 #6
0
ファイル: inventory.py プロジェクト: Bitmessage/PyBitmessage
 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