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

Correct detect proc by raising exception eagerly #79

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

sneakers-the-rat
Copy link
Contributor

Fixes #78

The problem was from changing the impl.iter_process_parents to a generator rather than a plan old iterator. The body of generators isn't evaluated until the first time their next method is called, so the check here:

except EnvironmentError:
continue

is incorrect because the environment error is raised here instead:

for proc_args, _, _ in _iter_process_parents(pid, max_depth):

or, when the generator is unpacked.

The fix is to just wrap the inner generator - so the detect_proc function is called in the expected place, and if it passes then the called generator is returned and equivalant to the current generator

@uranusjr uranusjr changed the title Fix #78 - proc incorrectly detected Correct detect proc by raising exception eagerly Aug 17, 2023
A generator's content isn't accessed until it's first called next()
against, which delays the exception from being raised. This messes up
our proc vs ps detection logic. By wrapping the generator in a nested
function, we can make the detection eager again and resolve the issue.
@uranusjr uranusjr merged commit ed3066f into sarugaku:master Aug 17, 2023
16 checks passed
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.

unsupported proc format
2 participants