folgendes Testprogramm
Code: Alles auswählen
from time import sleep
import threading
from concurrent import futures
#
def proc1():
while True:
sleep(1)
#
thread1 = futures.ThreadPoolExecutor(max_workers=1)
thread1.submit(proc1)
try:
while True:
sleep(1)
except KeyboardInterrupt:
print("Thread beenden")
thread1.shutdown()
exit()
Traceback:
Code: Alles auswählen
^CThread beenden
^CTraceback (most recent call last):
File "test-exception.py", line 16, in <module>
sleep(1)
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test-exception.py", line 19, in <module>
thread1.shutdown()
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 204, in shutdown
t.join()
File "/usr/lib/python3.7/threading.py", line 1032, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt
^CError in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 40, in _python_exit
t.join()
File "/usr/lib/python3.7/threading.py", line 1032, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt