-
Notifications
You must be signed in to change notification settings - Fork 220
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
[Unit tests] Popen() warning: subprocess is still running (non-deterministic). #1292
Comments
Thanks for analyzing this. I saw that problem, too but couldn't figure out what it is. ;) I vote for |
A unit tests uses the "object under test" ("OuT", eg. a class or even a single function) only for a short time. I the unit tests calls an OuT function with Note that Edit: So it may never be a problem in BiT itself but only during unit testing. But since unit tests shall succeed and no (unexpected) warning shall occur it is a problem eg. for TravisCI because a failing test may be a "false positive". |
Ah thanks. I got it now. ;) Then maybe such processed should be killed in a |
IMHO the running subprocess may occur also in BiT (but very rarely and only in case of errors). I will fix this in the BiT code directly, this is the cleanest solution I think (and not much work). |
Given the choice between the two solutions above, I would also prefer |
Before changing the Result: About 50 % of the The not covered calls are mostly not central to backup functionality. Overall risk estimation of this change: low Reasons:
Details: The following methods are currently not covered by a unit test:
|
Symptoms
When I execute unit tests with
common/make test-v
I get sometimes warnings like this (non-deterministically):/usr/lib64/python3.6/subprocess.py:786: ResourceWarning: subprocess 17750 is still running
Expected behavior
Analysis
Looking into the code locations I can see that subprocesses are mostly spawned with
subprocess.Popen()
+communicate()
code pattern to perform async subprocess calls:communicate()
willIn case of errors to
communicate()
with the subprocess it is not killed.Possible solutions
communicate
withproc.kill
after timeoutThere is a documented best-practice code snippet for this in the documentation:
with
to add context management (object lifecycle)Alternatively this code pattern could be used
https://docs.python.org/3/library/subprocess.html#subprocess.Popen
Impact
Using
with
requires context manager support fromPopen()
and this supported only for Python version 3.2 or higher.Using
with
means that BiP will no longer work for older Python versions (before 3.2).Others
Check if every code location with
Popen()
does usecommunicate()
tooThe text was updated successfully, but these errors were encountered: