本文整理汇总了Python中threadpool.ThreadPool.cleanUpThreads方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadPool.cleanUpThreads方法的具体用法?Python ThreadPool.cleanUpThreads怎么用?Python ThreadPool.cleanUpThreads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threadpool.ThreadPool
的用法示例。
在下文中一共展示了ThreadPool.cleanUpThreads方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: from threadpool import ThreadPool [as 别名]
# 或者: from threadpool.ThreadPool import cleanUpThreads [as 别名]
channels = list(db.channels.find())
client.disconnect() # probably not the most efficient, but the mongo client isn't thread safe
work_queue = Queue.Queue()
finish_events = []
tp = ThreadPool(multiprocessing.cpu_count(), queue_size=0, wait_timeout=1)
ii = ItemInserter(host, port, db_name, 'items', 'channels', work_queue, finish_events)
for channel in channels:
mod_date = None
try:
etag = channel['etag']
except KeyError:
etag = None
try:
mod_date = channel['last_modified']
except KeyError:
mod_date = None
e = threading.Event()
fp = ChannelFetcherParser(channel['url'], mod_date, etag, work_queue, e)
ii._finished.append(e)
tp.addTask(fp)
tp.addTask(ii)
work_queue.join()
tp.cleanUpThreads()