Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2@file 

3@brief Shortcut to *parallel*. 

4""" 

5from threading import Thread 

6from .threader import kill_thread # pylint: disable=E0611 

7 

8 

9class KThread(Thread): 

10 """ 

11 Add methods *kill* to :epkg:`*py:threading:Thread`. 

12 """ 

13 

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. 

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