File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change 18
18
logger = logging .getLogger (__name__ )
19
19
20
20
21
+ def apoptosis ():
22
+ """Tell the operating system to kill us. This is useful in case we cannot
23
+ die. For example, a child thread might refuse to die.
24
+ """
25
+ import os
26
+
27
+ # Windows option
28
+ if os .name == "nt" :
29
+ import subprocess
30
+
31
+ subprocess .run (["taskkill" , "/IM" , str (os .getpid ()), "/F" ])
32
+ # *Nix option
33
+ else :
34
+ os .kill (os .getpid (), signal .SIGKILL )
35
+
36
+
21
37
def resource_path (relative_path ):
22
38
"""Find a resource in a PyInstaller executable, or in the local directory"""
23
39
if hasattr (sys , "_MEIPASS" ):
@@ -407,11 +423,9 @@ def main():
407
423
# asyncio task that is hogging the CPU and not surrending control
408
424
# via await.
409
425
logger .warning ("Failed to stop event thread." )
410
- # Since asyncio is not behaving, we need to kill ourselves.
411
- if os .name == "nt" :
412
- subprocess .run (["taskkill" , "/IM" , str (os .getpid ()), "/F" ])
413
- else :
414
- os .kill (os .getpid (), signal .SIGKILL )
426
+ # Since asyncio is not behaving, we need the operating system to
427
+ # end this process
428
+ apoptosis ()
415
429
416
430
417
431
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments