简体   繁体   English

python:通过ID检查线程的状态

[英]python: Check status of thread by ID

I have a multithreading Python(2.7) program, which runs multiple threads for different tasks. 我有一个多线程Python(2.7)程序,该程序运行多个线程来执行不同的任务。 I am storing the thread-ids, for tracking the status of threads in a separate thread for status-tracking. 我存储线程ID,用于在单独的线程中跟踪线程的状态以进行状态跟踪。

How can I check the thread is alive or not ( isAlive() ) by having the thread-id ? 如何通过具有thread-id来检查线程是否处于活动状态( isAlive() )?

As far as I know, I don't believe there's a way to retrieve the thread by its thread_id. 据我所知,我不相信有一种方法可以通过thread_id来检索线程。 Your best bet would be to store a reference to the thread object itself. 最好的选择是存储对线程对象本身的引用。

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

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