本文整理汇总了Python中multiprocessing.Queue.conn_pool方法的典型用法代码示例。如果您正苦于以下问题:Python Queue.conn_pool方法的具体用法?Python Queue.conn_pool怎么用?Python Queue.conn_pool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.Queue
的用法示例。
在下文中一共展示了Queue.conn_pool方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _merge_parallel
# 需要导入模块: from multiprocessing import Queue [as 别名]
# 或者: from multiprocessing.Queue import conn_pool [as 别名]
def _merge_parallel(self, collection, geneid_set, step=100000, idmapping_d=None):
from multiprocessing import Process, Queue
NUMBER_OF_PROCESSES = 8
input_queue = Queue()
input_queue.conn_pool = []
def worker(q, target):
while True:
doc = q.get()
if doc == 'STOP':
break
__id = doc.pop('_id')
doc.pop('taxid', None)
target.update(__id, doc)
# target_collection.update({'_id': __id}, {'$set': doc},
# manipulate=False,
# upsert=False) #,safe=True)
# Start worker processes
for i in range(NUMBER_OF_PROCESSES):
Process(target=worker, args=(input_queue, self.target)).start()
for doc in doc_feeder(self.src[collection], step=step):
_id = doc['_id']
if idmapping_d:
_id = idmapping_d.get(_id, None) or _id
for __id in alwayslist(_id): # there could be cases that idmapping returns multiple entrez_gene ids.
__id = str(__id)
if __id in geneid_set:
doc['_id'] = __id
input_queue.put(doc)
# Tell child processes to stop
for i in range(NUMBER_OF_PROCESSES):
input_queue.put('STOP')