summaryrefslogtreecommitdiff
path: root/Lib/test/test_threading.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-01-05 03:54:28 +0000
committerVictor Stinner <victor.stinner@haypocalc.com>2011-01-05 03:54:28 +0000
commit055f89ff8e76831a78710d5d8a561d6a3d7de9ae (patch)
tree7b6b748ac9f56258152fa4173090d124068f3d18 /Lib/test/test_threading.py
parentf024bc1c2ee5fabfcae4beab32c387ccbe21d78c (diff)
downloadcpython-055f89ff8e76831a78710d5d8a561d6a3d7de9ae.tar.gz
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).
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r--Lib/test/test_threading.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index f3d5a4c89d..46d2f4723d 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()")