Python threading interrumpir el sueño
¿Hay alguna manera en Python para interrumpir un hilo cuando está durmiendo? (Como podemos hacer en Java)
Estoy buscando algo así.
import threading
from time import sleep
def f():
print('started')
try:
sleep(100)
print('finished')
except SleepInterruptedException:
print('interrupted')
t = threading.Thread(target=f)
t.start()
if input() == 'stop':
t.interrupt()
El hilo está durmiendo durante 100 segundos y si escribo 'detener', se interrumpe