Python 使用start\u new\u thread关闭线程的正确方法

Python 使用start\u new\u thread关闭线程的正确方法,python,multithreading,Python,Multithreading,继承了一个使用pythons旧线程模块的项目。在将来的某个时候,我会转而使用线程技术,但是现在我会使用我得到的。使用start\u new\u thread关闭线程的正确方法是什么。这是我目前的代码: ac_thread = start_new_thread(get_token_every_two_minutes, (driver.current_url, q)) time.sleep(20) ac_thread.exit() 我得到的例外是: Unhandled exception in t

继承了一个使用pythons旧线程模块的项目。在将来的某个时候,我会转而使用线程技术,但是现在我会使用我得到的。使用start\u new\u thread关闭线程的正确方法是什么。这是我目前的代码:

ac_thread = start_new_thread(get_token_every_two_minutes, (driver.current_url, q))
time.sleep(20)
ac_thread.exit()
我得到的例外是:

Unhandled exception in thread started by <function thread_flow at 0x0396CB30>
Traceback (most recent call last):
  File "G:\common_functions.py", line 609, in thread_flow
ac_thread.exit()
AttributeError: 'int' object has no attribute 'exit'
国防部说:

启动新线程并返回其标识符。

此标识符是一个
int
,当然没有“exit”属性

关于关闭线程;线程将以静默方式退出(完成后),或者当函数以未处理的异常终止时,打印堆栈跟踪,然后线程退出

Raise the SystemExit exception. When not caught, this will cause the thread to exit silently.