Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-126083: Fix a reference leak in asyncio.Task when reinitializing with new non-None context#126103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
gh-126083: Fix a reference leak in asyncio.Task when reinitializing with new non-None context #126103
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2688,6 +2688,28 @@ def test_get_context(self): | ||
| finally: | ||
| loop.close() | ||
| def test_proper_refcounts(self): | ||
| # see: https://github.com/python/cpython/issues/126083 | ||
| class Break: | ||
| def __str__(self): | ||
| raise RuntimeError("break") | ||
| obj = object() | ||
| initial_refcount = sys.getrefcount(obj) | ||
| coro = coroutine_function() | ||
| loop = asyncio.new_event_loop() | ||
| task = asyncio.Task.__new__(asyncio.Task) | ||
| for _ in range(5): | ||
| with self.assertRaisesRegex(RuntimeError, 'break'): | ||
| task.__init__(coro, loop=loop, context=obj, name=Break()) | ||
| coro.close() | ||
| del task | ||
Nico-Posada marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| self.assertEqual(sys.getrefcount(obj), initial_refcount) | ||
Contributor
| ||
| def add_subclass_tests(cls): | ||
| BaseTask = cls.Task | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixed a reference leak in :class:`asyncio.Task` objects when reinitializing the same object with a non-``None`` context. Patch by Nico Posada. |
Uh oh!
There was an error while loading. Please reload this page.