只有一个功能,杀死线程!
Project description
Kill Thread
只有一个功能,杀死线程!
安装
pip install kill-thread
示例
import time
import datetime
import threading
from kill_thread import kill_thread
def print_time():
while True:
time.sleep(1)
print(datetime.datetime.now())
# 生成启动一个每隔一秒打印当前时间的线程
thread = threading.Thread(target=print_time)
thread.start()
# 十秒后杀死线程
time.sleep(10)
kill_thread(thread)
# 阻塞主线程观察打印时间的线程是否被杀死
input('按任意键终止主线程')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kill-thread-0.0.1.tar.gz
(6.2 kB
view hashes)
Built Distribution
kill_thread-0.0.1-py3.9.egg
(2.2 kB
view hashes)