1
"""
2
@file
3
@brief Shortcut to *parallel*.
4
"""
5 1
from threading import Thread
6 1
from .threader import kill_thread  # pylint: disable=E0611
7

8

9 1
class KThread(Thread):
10
    """
11
    Add methods *kill* to :epkg:`*py:threading:Thread`.
12
    """
13

14 1
    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.
21

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

Read our documentation on viewing source code .

Loading