我有一段使用ProcessPoolExecutor处理多个表的代码。现在一些表非常轻,所以处理它们非常简单,但对于一些表,代码确实很困难,cpu可能会在一段时间内达到99%。我已经在尽可能地使用睡眠,甚至减少了工作人员的数量。但这些都没有用。所以我想知道使用nice是否对我有帮助?
遗憾的是,这就是我所能分享的全部,因为代码相当长。
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)我之所以问这个问题,是因为当我调用结果时,我得到了一个日志,表明我的所有子进程在中途停止工作。示例:
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'

发布于 2021-05-11 20:22:54
nice是由子进程继承的;所以是的。这应该很容易在实验中建立;在几个进程中运行sleep 120,并在ps清单中检查它们的值。
当然,如果您的服务器耗尽了电源,那么nice将无能为力。您是否耗尽了内存、进程、可用文件句柄、套接字或磁盘空间?然后修复这些东西。
https://stackoverflow.com/questions/67455640
复制相似问题