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 924a6ce

Browse filesBrowse files
[3.13] gh-127949: fix resource warnings in test_tasks.py (GH-128172) (#131805)
gh-127949: fix resource warnings in `test_tasks.py` (GH-128172) (cherry picked from commit b66a4ad) Co-authored-by: Thomas Grainger <tagrain@gmail.com>
1 parent 7f7fc54 commit 924a6ce
Copy full SHA for 924a6ce

File tree

1 file changed

+8
-8
lines changed
Filter options

1 file changed

+8
-8
lines changed

‎Lib/test/test_asyncio/test_tasks.py

Copy file name to clipboardExpand all lines: Lib/test/test_asyncio/test_tasks.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,17 +2694,17 @@ def __str__(self):
26942694
initial_refcount = sys.getrefcount(obj)
26952695

26962696
coro = coroutine_function()
2697-
loop = asyncio.new_event_loop()
2698-
task = asyncio.Task.__new__(asyncio.Task)
2697+
with contextlib.closing(asyncio.EventLoop()) as loop:
2698+
task = asyncio.Task.__new__(asyncio.Task)
26992699

2700-
for _ in range(5):
2701-
with self.assertRaisesRegex(RuntimeError, 'break'):
2702-
task.__init__(coro, loop=loop, context=obj, name=Break())
2700+
for _ in range(5):
2701+
with self.assertRaisesRegex(RuntimeError, 'break'):
2702+
task.__init__(coro, loop=loop, context=obj, name=Break())
27032703

2704-
coro.close()
2705-
del task
2704+
coro.close()
2705+
del task
27062706

2707-
self.assertEqual(sys.getrefcount(obj), initial_refcount)
2707+
self.assertEqual(sys.getrefcount(obj), initial_refcount)
27082708

27092709

27102710
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.