Clean up nanny WorkerProcess.kill
#6972
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm hoping that this resolves #6971, though it may not.
This fixes a couple things:
mark_stopped
, which setschild_stop_q
to None among other things. So betweenself.child_stop_q.put
andself.child_stop_q.close
,self.child_stop_q
could have become None, since there's anawait
in between. That caused theAttributeError: 'NoneType' object has no attribute 'close'
.process.join
, afterprocess.close
has been called (inmark_stopped
). That will causejoin
to raise a ValueError. This is fine—it means we can just exit—but we should catch that. I went for a string match on the ValueError since ValueError feels like too generic of an exception type to just ignore IMO.I have no idea how to test this. The condition we're looking for is the subprocess exiting in between an
await sleep(0)
. That's extremely hard to trigger. (I'm also not sure it still needs to be there??)Closes #6971
pre-commit run --all-files