mirror of
https://github.com/python/cpython.git
synced 2025-08-08 10:58:51 +00:00
[3.9] bpo-25130: Add calls of gc.collect() in tests to support PyPy (GH-28005). (GH-28028)
(cherry picked from commit 2a8127cafe
)
This commit is contained in:
parent
dab74d68e3
commit
330aabbbbe
36 changed files with 143 additions and 15 deletions
|
@ -448,6 +448,7 @@ class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest, BaseTestCase
|
|||
executor.map(abs, range(-5, 5))
|
||||
threads = executor._threads
|
||||
del executor
|
||||
support.gc_collect() # For PyPy or other GCs.
|
||||
|
||||
for t in threads:
|
||||
self.assertRegex(t.name, r'^SpecialPool_[0-4]$')
|
||||
|
@ -458,6 +459,7 @@ class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest, BaseTestCase
|
|||
executor.map(abs, range(-5, 5))
|
||||
threads = executor._threads
|
||||
del executor
|
||||
support.gc_collect() # For PyPy or other GCs.
|
||||
|
||||
for t in threads:
|
||||
# Ensure that our default name is reasonably sane and unique when
|
||||
|
@ -520,6 +522,7 @@ class ProcessPoolShutdownTest(ExecutorShutdownTest):
|
|||
call_queue = executor._call_queue
|
||||
executor_manager_thread = executor._executor_manager_thread
|
||||
del executor
|
||||
support.gc_collect() # For PyPy or other GCs.
|
||||
|
||||
# Make sure that all the executor resources were properly cleaned by
|
||||
# the shutdown process
|
||||
|
@ -744,6 +747,7 @@ class AsCompletedTests:
|
|||
futures_list.remove(future)
|
||||
wr = weakref.ref(future)
|
||||
del future
|
||||
support.gc_collect() # For PyPy or other GCs.
|
||||
self.assertIsNone(wr())
|
||||
|
||||
futures_list[0].set_result("test")
|
||||
|
@ -751,6 +755,7 @@ class AsCompletedTests:
|
|||
futures_list.remove(future)
|
||||
wr = weakref.ref(future)
|
||||
del future
|
||||
support.gc_collect() # For PyPy or other GCs.
|
||||
self.assertIsNone(wr())
|
||||
if futures_list:
|
||||
futures_list[0].set_result("test")
|
||||
|
@ -850,6 +855,7 @@ class ExecutorTest:
|
|||
for obj in self.executor.map(make_dummy_object, range(10)):
|
||||
wr = weakref.ref(obj)
|
||||
del obj
|
||||
support.gc_collect() # For PyPy or other GCs.
|
||||
self.assertIsNone(wr())
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue