Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d4ddc03

Browse filesBrowse files
miss-islingtongraingertkumaraditya303
authored
[3.12] gh-127949: fix resource warnings in test_tasks.py (GH-128172) (#131806)
* gh-127949: fix resource warnings in `test_tasks.py` (GH-128172) (cherry picked from commit b66a4ad) Co-authored-by: Thomas Grainger <tagrain@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
1 parent 940c937 commit d4ddc03
Copy full SHA for d4ddc03

File tree

1 file changed

+9
-8
lines changed
Filter options

1 file changed

+9
-8
lines changed

‎Lib/test/test_asyncio/test_tasks.py

Copy file name to clipboardExpand all lines: Lib/test/test_asyncio/test_tasks.py
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for tasks.py."""
22

33
import collections
4+
import contextlib
45
import contextvars
56
import gc
67
import io
@@ -2499,17 +2500,17 @@ def __str__(self):
24992500
initial_refcount = sys.getrefcount(obj)
25002501

25012502
coro = coroutine_function()
2502-
loop = asyncio.new_event_loop()
2503-
task = asyncio.Task.__new__(asyncio.Task)
2503+
with contextlib.closing(asyncio.new_event_loop()) as loop:
2504+
task = asyncio.Task.__new__(asyncio.Task)
25042505

2505-
for _ in range(5):
2506-
with self.assertRaisesRegex(RuntimeError, 'break'):
2507-
task.__init__(coro, loop=loop, context=obj, name=Break())
2506+
for _ in range(5):
2507+
with self.assertRaisesRegex(RuntimeError, 'break'):
2508+
task.__init__(coro, loop=loop, context=obj, name=Break())
25082509

2509-
coro.close()
2510-
del task
2510+
coro.close()
2511+
del task
25112512

2512-
self.assertEqual(sys.getrefcount(obj), initial_refcount)
2513+
self.assertEqual(sys.getrefcount(obj), initial_refcount)
25132514

25142515

25152516
def add_subclass_tests(cls):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.