简体   繁体   English

确实影响 ProcessPoolExecutor

[英]does nice affect ProcessPoolExecutor

I have a code that uses ProcessPoolExecutor to process multiple tables.我有一个使用ProcessPoolExecutor处理多个表的代码。 Now some of the tables are really light so processing them is quite simple, but for some of the tables the code really struggles and the cpu can be at 99% for a while.现在有些表真的很轻,所以处理它们很简单,但是对于一些表,代码真的很困难,cpu 可以在一段时间内达到 99%。 I'm already using sleep whenever I can, and even lowered the amount of workers.我已经尽可能地使用睡眠,甚至减少了工人的数量。 But none of it helped.但这些都没有帮助。 So I wonder if maybe using nice could help me?所以我想知道是否使用 nice 可以帮助我?

Sadly that's all I can share because the code is quite long.遗憾的是,我只能分享这些,因为代码很长。

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)

I'm asking because when i call for the the results, I get a log that all of my sub processes stopped working in the middle.我问是因为当我要求结果时,我得到一个日志,表明我的所有子进程都在中间停止工作。 Example:例子:

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.

I'm using Ubuntu 18.04.3 LTS.我正在使用 Ubuntu 18.04.3 LTS。 My OOM error from the command dmesg -T | egrep -i 'killed process'命令dmesg -T | egrep -i 'killed process'我的 OOM 错误dmesg -T | egrep -i 'killed process' 在此处输入图像描述

nice is inherited by subprocesses; nice被子进程继承; so yes.所以是的。 It should be easy to establish experimentally;应该很容易通过实验建立; run sleep 120 in several processes and examine their nice value in a ps listing.在几个进程中运行sleep 120并在ps列表中检查它们的好值。

Of course, if your server is running out of juice, there is no way that nice will help.当然,如果您的服务器快没电了, nice也无济于事。 Are you running out of memory, or processes, or free file handles, or sockets, or disk space?您是否用完了 memory、进程、空闲文件句柄、sockets 或磁盘空间? Then fix those things instead.然后改正这些东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM