Skip to content

👌 IMPROVE: Check for recycled circus PID #4858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions aiida/cmdline/utils/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,13 @@ class StartCircusNotFound(Exception):
if pid is not None:
try:
process = psutil.Process(pid)
# the PID got recycled, but a different process
if _START_CIRCUS_COMMAND not in process.cmdline():
raise StartCircusNotFound() # Also this is a case in which the process is not there anymore

# the PID got recycled, but for a daemon of someone else
if process.username() != psutil.Process().username(): # compare against the username of this interpreter
raise StartCircusNotFound()
except (psutil.AccessDenied, psutil.NoSuchProcess, StartCircusNotFound):
echo.echo_warning(
f'Deleted apparently stale daemon PID file as its associated process<{pid}> does not exist anymore'
Expand Down