Handle properly a psutil exception. Closes #501

This commit is contained in:
Manuel Cortez 2022-12-13 11:16:10 -06:00
parent a3bc684721
commit 3adc726f33
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790

View File

@ -115,12 +115,13 @@ def check_pid():
if os.path.exists(pidpath):
with open(pidpath) as fin:
pid = int(fin.read())
p = psutil.Process(pid=pid)
if p.is_running():
# Display warning dialog
commonMessageDialogs.common_error(_("{0} is already running. Close the other instance before starting this one. If you're sure that {0} isn't running, try deleting the file at {1}. If you're unsure of how to do this, contact the {0} developers.").format(application.name, pidpath))
sys.exit(1)
else:
try:
p = psutil.Process(pid=pid)
if p.is_running():
# Display warning dialog
commonMessageDialogs.common_error(_("{0} is already running. Close the other instance before starting this one. If you're sure that {0} isn't running, try deleting the file at {1}. If you're unsure of how to do this, contact the {0} developers.").format(application.name, pidpath))
sys.exit(1)
except psutil.NoSuchProcess:
commonMessageDialogs.dead_pid()
# Write the new PID
with open(pidpath,"w") as cam: