Skip to content
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

Ignore psutil exceptions in _find_agent. #203

Merged
merged 1 commit into from
Jul 25, 2018

Conversation

peter50216
Copy link

Fix #201.
When there's zombie process in system or some process disappears before listing and getting attributes, methods on proc would raise psutil.Error, and the import gnupg statement would fail.

@phryk
Copy link

phryk commented Aug 14, 2017

Hey Peter. I don't know nearly enough about the architecture of this module to gauge whether it's wise to ignore all psutil errors. Maybe psutil.ZombieProcess or psutil.NoSuchProcess would be a more fitting exception to catch?

@peter50216
Copy link
Author

Since the _find_agent function is run at import time, I still think we should ignore all psutil exceptions.
To me, it feels worse that import failed due to status of other process than not finding the right gpg-agent.
Also according to document, there are only three exceptions NoSuchProcess, AccessDenied, TimeoutExpired that are psutil.Error. (ZombieProcess is subclass for NoSuchProcess)
TimeoutExpired shouldn't be raised here, and I guess we'll want to ignore AccessDenied too.

@mdsn
Copy link

mdsn commented Jun 4, 2018

Bumping this PR. Is there further work that needs to be done for it to be merged? Thanks.

@msheiny
Copy link

msheiny commented Jul 6, 2018

Yeah we also independently ran into this issue, implemented the same fix, was about to make a PR and then saw this ticket 👍

@isislovecruft
Copy link
Owner

Hi @peter50216! Thank you for the patch, and I'm very sorry for the delays in reviewing it and getting it merged.

except psutil.Error:
# Exception when getting proc info, possibly because the
# process is zombie / process no longer exist. Just ignore it.
pass
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to log when these errors occur, just in case, so that it doesn't silently cause something else to fail in some edge case in the future. I'm happy to make that change myself after merging your patch.

isislovecruft added a commit that referenced this pull request Jul 25, 2018
@isislovecruft isislovecruft merged commit 8ba886e into isislovecruft:master Jul 25, 2018
@isislovecruft
Copy link
Owner

Merged and in version 3.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants