CPUlimitがプロセスを停止するのはなぜですか?

CPUlimitがプロセスを停止するのはなぜですか?

私はグラフでいくつかのアルゴリズムを実行するためにnetworkxパッケージを使用するPythonスクリプトを実行しています。

スクリプトは

import networkx as nx
from networkx.algorithms.approximation import clique

G = nx.read_adjlist("newman_one_mode.adj")
print "the number of nodes in the graph is: " + str(G.number_of_nodes())
max_clique_nodes = clique.max_clique(G)
print "the clique nodes are: " + str(max_clique_nodes)

時間がかかり、CPU使用量(99%)が高いため、CPU使用量を制限したいと思います。

このプロセスでは、cpulimitを使用してCPU使用率を60%に制限します。

cpulimit -p 29780 -l 60

ちなみに使用すると、以下のようにプロセスが停止します。

[lily@geland academic]$ python run.py
the number of nodes in the graph is: 16264

[1]+  Stopped                 python run.py

何が間違っていて、この状況をどのように処理するのですか?ありがとうございます!

追加情報: cpulimitを実行しないと、プロセスは長時間実行されてから終了します。理由はわかりません。おそらくリソースが枯渇しているからです。

[lily@geland academic]$ python run.py
the number of nodes in the graph is: 16264
[1]+  Terminated              python run.py
Killed

ベストアンサー1

これは予想される動作です。

cpulimit は CPU リソースが多すぎるとプロセスを一時停止し、一定時間が経過するとプロセスを再開します。

また、スクリプトが入力を待っていることを確認してください。その場合、スクリプトも停止した状態になります。

stdinをリダイレクトしてcpulimitを再実行してみてください。例:python run.py < /dev/null &

おすすめ記事