summaryrefslogtreecommitdiff
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-06-01 15:51:02 +0200
committerGitHub <noreply@github.com>2018-06-01 15:51:02 +0200
commit5dbb48aaac0ff74648b355ebdde222856004b1ef (patch)
treec47bd93d6333eb31b1461d75c5463ef058d666b2 /Lib/test/test_socket.py
parent95681c7a7ddd436ba7d6c10d1202c33dd6bd648b (diff)
downloadcpython-git-5dbb48aaac0ff74648b355ebdde222856004b1ef.tar.gz
[3.6] bpo-31234: Add test.support.wait_threads_exit() (GH-3578) (GH-7315)
* bpo-31234: Add test.support.wait_threads_exit() (GH-3578) Use _thread.count() to wait until threads exit. The new context manager prevents the "dangling thread" warning. (cherry picked from commit ff40ecda73178dfcad24e26240d684356ef20793) * bpo-31234: Try to fix lock_tests warning (#3557) Try to fix the "Warning -- threading_cleanup() failed to cleanup 1 threads" warning in test.lock_tests: wait a little bit longer to give time to the threads to complete. Warning seen on test_thread and test_importlib. (cherry picked from commit 096ae3373abac2c8b3a26a3fe33cc8bd4cbccd4e)
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r--Lib/test/test_socket.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 2d2ec04fc0..e41ddfd8af 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -245,6 +245,9 @@ class ThreadableTest:
self.server_ready.set()
def _setUp(self):
+ self.wait_threads = support.wait_threads_exit()
+ self.wait_threads.__enter__()
+
self.server_ready = threading.Event()
self.client_ready = threading.Event()
self.done = threading.Event()
@@ -271,6 +274,7 @@ class ThreadableTest:
def _tearDown(self):
self.__tearDown()
self.done.wait()
+ self.wait_threads.__exit__(None, None, None)
if self.queue.qsize():
exc = self.queue.get()