isislovecruft / python-gnupg

A modified version of python-gnupg, including security patches, extensive documentation, and extra features.
Other
424 stars 172 forks source link

Ignore psutil exceptions in _find_agent. #203

Closed peter50216 closed 6 years ago

peter50216 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

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

msheiny commented 6 years ago

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

isislovecruft commented 6 years ago

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

isislovecruft commented 6 years ago

Merged and in version 3.0.1.