diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-01-05 03:54:28 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-01-05 03:54:28 (GMT) |
commit | c932b65428b4995bc53609ed361fddf382882ee5 (patch) | |
tree | e2cac3eff5a4c6fb3f3a57ec3f7c2fb174d64160 | |
parent | 4b2b43d9889b498c1dc71b8a2bef8cfea45f410c (diff) | |
download | cpython-c932b65428b4995bc53609ed361fddf382882ee5.zip cpython-c932b65428b4995bc53609ed361fddf382882ee5.tar.gz cpython-c932b65428b4995bc53609ed361fddf382882ee5.tar.bz2 |
test_threading: use Popen.communicate() instead of .wait()
Popen.communicate() avoids deadlocks and close the pipes when done. This commit
fixes a ResourceWarning(unclosed pipe).
-rw-r--r-- | Lib/test/test_threading.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index f3d5a4c..46d2f47 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -512,9 +512,9 @@ class ThreadJoinOnShutdown(BaseTestCase): def assertScriptHasOutput(self, script, expected_output): p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE) - rc = p.wait() - data = p.stdout.read().decode().replace('\r', '') - self.assertEqual(rc, 0, "Unexpected error") + stdout, stderr = p.communicate() + data = stdout.decode().replace('\r', '') + self.assertEqual(p.returncode, 0, "Unexpected error") self.assertEqual(data, expected_output) @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") |