[update] termination

This commit is contained in:
Eshan Roy (Eshanized)
2024-04-25 10:15:58 +05:30
parent dc0cc59684
commit 5499d6e9bd
2 changed files with 49 additions and 6 deletions

View File

@@ -1806,3 +1806,52 @@ def check_if_process_running(process_name):
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False
def terminate_pacman():
try:
process_found = False
for proc in psutil.process_iter():
try:
pinfo = proc.as_dict(attrs=["pid", "name", "create_time"])
if pinfo["name"] == "pacman":
process_found = True
logger.debug(
"Killing Pacman Process: %s" %pinfo["name"]
)
proc.kill()
except (psutil.NoSuchProcess, psutil.AccessDenied):
continue
if process_found == True:
if check_pacman_lockfile():
os.unlink(pacman_lockfile)
except Exception as e:
logger.error(
"Found Exception in LOC1810: %s" % e
)
def check_pacman_lockfile():
try:
if os.path.exists(pacman_lockfile):
return True
else:
return False
except Exception as e:
logger.error(
"Found Exception in LOC1832: %s" % e
)
def is_thread_alive(thread_name):
for thread in threading.enumerate():
if thread.name == thread_name and thread.is_alive():
return True
return False
def print_running_threads():
threads_alive = []
for thread in threading.enumerate():
if thread.is_alive():
threads_alive.append(thread.name)
for th in threads_alive:
logger.debug(
"Thread: %s Status: Alive" % th
)

View File

@@ -1,11 +1,5 @@
#!/bin/python
'''
NOTE: Don't use any virtual environment as we need gi and Gtk
'''
# Module Import
import os
import sys
import time