当前位置: 首页>>代码示例>>Python>>正文


Python Pool.starmap方法代码示例

本文整理汇总了Python中multiprocessing.pool.Pool.starmap方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.starmap方法的具体用法?Python Pool.starmap怎么用?Python Pool.starmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在multiprocessing.pool.Pool的用法示例。


在下文中一共展示了Pool.starmap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from multiprocessing.pool import Pool [as 别名]
# 或者: from multiprocessing.pool.Pool import starmap [as 别名]
 def update(self, export='csv', path='out'):
     stock_codes = []
     for file in os.listdir(os.path.join(path, 'raw_data')):
         if not file.endswith('csv'):
             continue
         stock_code = file[:-4]
         stock_codes.append(stock_code)
     pool = Pool(10)
     params = [(code, path) for code in stock_codes]
     if export.lower() in ['csv']:
         pool.starmap(self.update_single_code, params)
开发者ID:Thinkflyer,项目名称:easyhistory,代码行数:13,代码来源:day.py

示例2: _process

# 需要导入模块: from multiprocessing.pool import Pool [as 别名]
# 或者: from multiprocessing.pool.Pool import starmap [as 别名]
    def _process(cls, spectrum, filter_spectrum, *args):
        """This private class method process spectrum with a given filter
        and parameters.

        .. note:: If no filter spectrum is provided, then it passes None as
                  filter spectrum point to all processes.

        This method uses multiprocessing.
        """
        if filter_spectrum:
            resampled_filter_spectrum = filter_spectrum.resample(spectrum)
            resampled_filter_lines = resampled_filter_spectrum.lines
        else:
            resampled_filter_lines = repeat(None, len(spectrum.lines))
        data = zip(spectrum.lines, resampled_filter_lines, repeat(args))
        p = Pool()
        y_values = p.starmap(cls._func, data)
        p.close()
        p.join()
        lines = zip(spectrum.x_values, y_values)
        return type(spectrum)(lines, interpolation=spectrum.interpolation)
开发者ID:industrialsynthfreak,项目名称:spectral-tools,代码行数:23,代码来源:filter.py

示例3: Article

# 需要导入模块: from multiprocessing.pool import Pool [as 别名]
# 或者: from multiprocessing.pool.Pool import starmap [as 别名]
    article = Article(URL_PREFIX + "/wiki/Special:Export/Template:Periodic_table")
    categories = []
    params = []
    for row in article.get_table("table 1"):
        for key, value in row.items():
            segments = [segment.strip() for segment in value.split(";")]
            if len(segments) >= 7:
                if segments[5].lower() not in categories:
                    categories.append(segments[5].lower())
                params.append(
                    (
                        segments[1],
                        segments[7].replace(" ", "_") if len(segments) > 7 else segments[1].capitalize(),
                        ionization_energies,
                        element_names,
                        categories.index(segments[5].lower()),
                    )
                )

    pool = Pool(processes=multiprocessing.cpu_count() * 2)

    json_data = pool.starmap(parse, params)
    pool.close()
    pool.join()

    # Save

    with open(OUTPUT_JSON, "w+") as outfile:
        json.dump(json_data, outfile, sort_keys=True, indent=4, ensure_ascii=False)
开发者ID:superzak1,项目名称:android-periodic-table,代码行数:31,代码来源:build_db.py


注:本文中的multiprocessing.pool.Pool.starmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。