Coverage for cpyquickhelper/parallel/threadhelper.py: 100%
4 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-30 05:30 +0200
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-30 05:30 +0200
1"""
2@file
3@brief Shortcut to *parallel*.
4"""
5from threading import Thread
6from .threader import kill_thread # pylint: disable=E0611
9class KThread(Thread):
10 """
11 Add methods *kill* to :epkg:`*py:threading:Thread`.
12 """
14 def kill(self):
15 """
16 Kills the thread if not alreayd finished.
17 Source: `Python-Kill-Thread-Extension <https://github.com/munawarb/Python-Kill-Thread-Extension>`_.
18 The function still does not work. The found example
19 is not really working and it is not safe anyway as it will
20 leave the garbage collector in an unstable state.
22 @return None if not alive, exit code otherwise.
23 """
24 if self.is_alive(): # pragma: no cover
25 return kill_thread(self.ident)
26 return None # pragma: no cover