-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Seen in https://buildbot.python.org/#/builders/1368/builds/2775/steps/6/logs/stdio
The test attempts to ensure that the executor doesn't hold on to the result object, but the executor necessarily holds onto it for a brief period from when it sets the result in in the future until the variable goes out of scope.
We should use support.sleeping_retry
to check if the weakref eventually (ideally quickly) becomes dead.
======================================================================
FAIL: test_free_reference (test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_free_reference)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/ec2-user/buildbot/buildarea/3.x.itamaro-macos-arm64-aws.macos-with-brew.refleak.nogil/build/Lib/test/test_concurrent_futures/executor.py", line 132, in test_free_reference
self.assertIsNone(wr())
~~~~~~~~~~~~~~~~~^^^^^^
AssertionError: <test.test_concurrent_futures.executor.MyObject object at 0x200041b0100> is not None
----------------------------------------------------------------------
cpython/Lib/test/test_concurrent_futures/executor.py
Lines 125 to 132 in 12db452
def test_free_reference(self): | |
# Issue #14406: Result iterator should not keep an internal | |
# reference to result objects. | |
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()) |
cpython/Lib/concurrent/futures/thread.py
Lines 85 to 92 in 12db452
try: | |
result = ctx.run(self.task) | |
except BaseException as exc: | |
self.future.set_exception(exc) | |
# Break a reference cycle with the exception 'exc' | |
self = None | |
else: | |
self.future.set_result(result) |
Linked PRs
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error