首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nice会影响ProcessPoolExecutor吗

nice会影响ProcessPoolExecutor吗
EN

Stack Overflow用户
提问于 2021-05-09 16:21:25
回答 1查看 71关注 0票数 2

我有一段使用ProcessPoolExecutor处理多个表的代码。现在一些表非常轻,所以处理它们非常简单,但对于一些表,代码确实很困难,cpu可能会在一段时间内达到99%。我已经在尽可能地使用睡眠,甚至减少了工作人员的数量。但这些都没有用。所以我想知道使用nice是否对我有帮助?

遗憾的是,这就是我所能分享的全部,因为代码相当长。

代码语言:javascript
复制
with ProcessPoolExecutor(max_workers=NUM_OF_PROCESS_WORKERS) as process_executor:
    process_sstables_per_node(env_tables_dict, nodes, process_executor)


def process_sstables_per_node(env_tables_dict, nodes, process_executor):
    for table_type in TABLES_COLUMNS_MAPPER.keys():
        for node in nodes:
            key = os.path.join(node, table_type)
            env_tables_dict[key] = process_executor.submit(handle_sstable_group_files_per_node, node, table_type)

我之所以问这个问题,是因为当我调用结果时,我得到了一个日志,表明我的所有子进程在中途停止工作。示例:

代码语言:javascript
复制
Traceback (most recent call last):
  File "main.py", line 49, in main
    future.result(timeout=RESULT_TIMEOUT * TIME_CONVERTOR * TIME_CONVERTOR)
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 425, in result
    return self.__get_result()
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.

我使用的是Ubuntu 18.04.3 LTS。我的OOM错误来自命令dmesg -T | egrep -i 'killed process'

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-11 20:22:54

nice是由子进程继承的;所以是的。这应该很容易在实验中建立;在几个进程中运行sleep 120,并在ps清单中检查它们的值。

当然,如果您的服务器耗尽了电源,那么nice将无能为力。您是否耗尽了内存、进程、可用文件句柄、套接字或磁盘空间?然后修复这些东西。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67455640

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档