blob: 7bb90d1b464cd75e882825a52ca6b6904df9d23a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import threading
from ..exceptions import InkstitchException
from ..debug import debug
class ExitThread(InkstitchException):
"""This exception is thrown in a thread to cause it to terminate.
Presumably we should only catch this at the thread's top level.
"""
pass
_default_stop_flag = threading.Event()
def check_stop_flag():
if getattr(threading.current_thread(), 'stop', _default_stop_flag).is_set():
debug.log("exiting thread")
raise ExitThread()
|