mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-128002: use per threads tasks linked list in asyncio (#128869)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
b4ff8b22b3
commit
0d68b14a0d
7 changed files with 156 additions and 58 deletions
|
|
@ -3,7 +3,8 @@
|
|||
import unittest
|
||||
from threading import Thread
|
||||
from unittest import TestCase
|
||||
|
||||
import weakref
|
||||
from test import support
|
||||
from test.support import threading_helper
|
||||
|
||||
threading_helper.requires_working_threading(module=True)
|
||||
|
|
@ -95,6 +96,22 @@ def check():
|
|||
done.set()
|
||||
runner.join()
|
||||
|
||||
def test_task_different_thread_finalized(self) -> None:
|
||||
task = None
|
||||
async def func():
|
||||
nonlocal task
|
||||
task = asyncio.current_task()
|
||||
|
||||
thread = Thread(target=lambda: asyncio.run(func()))
|
||||
thread.start()
|
||||
thread.join()
|
||||
wr = weakref.ref(task)
|
||||
del thread
|
||||
del task
|
||||
# task finalization in different thread shouldn't crash
|
||||
support.gc_collect()
|
||||
self.assertIsNone(wr())
|
||||
|
||||
def test_run_coroutine_threadsafe(self) -> None:
|
||||
results = []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue