当我为 Python 线程设置名称时,它不会显示在 htop 或 ps 上。ps 输出仅显示python
为线程名称。有没有办法设置一个线程名称,以便它显示在像它们这样的系统报告中?
from threading import Thread
import time
def sleeper():
while True:
time.sleep(10)
print "sleeping"
t = Thread(target=sleeper, name="Sleeper01")
t.start()
t.join()
ps -T -p {PID} 输出
PID SPID TTY TIME CMD
31420 31420 pts/30 00:00:00 python
31420 31421 pts/30 00:00:00 python