utils.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:plugin.audio.spotify 作者: marcelveldt 项目源码 文件源码
def process_method_on_list(method_to_run, items):
    '''helper method that processes a method on each listitem with pooling if the system supports it'''
    all_items = []
    if SUPPORTS_POOL:
        pool = ThreadPool()
        try:
            all_items = pool.map(method_to_run, items)
        except Exception:
            # catch exception to prevent threadpool running forever
            log_msg(format_exc(sys.exc_info()))
            log_msg("Error in %s" % method_to_run)
        pool.close()
        pool.join()
    else:
        all_items = [method_to_run(item) for item in items]
    all_items = filter(None, all_items)
    return all_items
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号