Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1a39d41
switch to per thread tasks list
kumaraditya303 Jan 11, 2025
28735e7
traverse linked lists of all threads
kumaraditya303 Jan 12, 2025
3052330
cleanup
kumaraditya303 Jan 14, 2025
acef821
add comments
kumaraditya303 Jan 15, 2025
237a089
add a per interp tasks list
kumaraditya303 Jan 16, 2025
c12f271
fixup for regular builds
kumaraditya303 Jan 16, 2025
d36270f
fix missing start world
kumaraditya303 Jan 16, 2025
f863cd5
Merge branch 'main' of https://github.com/python/cpython into per-thr…
kumaraditya303 Jan 21, 2025
d0fbbc2
add interp llist
kumaraditya303 Jan 21, 2025
5f5b95e
add more tests
kumaraditya303 Jan 21, 2025
708b410
fix test
kumaraditya303 Jan 21, 2025
2c1e93e
try fix compilation
kumaraditya303 Jan 21, 2025
c0ce361
remove supp
kumaraditya303 Jan 21, 2025
aa4c2d1
Merge branch 'main' of https://github.com/python/cpython into per-thr…
kumaraditya303 Jan 24, 2025
fd3fc0b
Merge branch 'main' of https://github.com/python/cpython into per-thr…
kumaraditya303 Jan 24, 2025
c45c9d7
fix merge
kumaraditya303 Jan 24, 2025
f0a9e53
Merge branch 'main' into per-thread-tasks
kumaraditya303 Jan 25, 2025
5b33c45
code review
kumaraditya303 Jan 29, 2025
1d73843
cleanup
kumaraditya303 Jan 29, 2025
4014e70
add comment for asyncio_tasks_lock
kumaraditya303 Jan 29, 2025
83aec26
Reword explanation
ambv Feb 6, 2025
e52741f
Merge branch 'main' into per-thread-tasks
ambv Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add more tests
  • Loading branch information
kumaraditya303 committed Jan 21, 2025
commit 5f5b95edd5d8813c71e60d2e75f34272024f6177
40 changes: 40 additions & 0 deletions Lib/test/test_asyncio/test_free_threading.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import asyncio
import unittest
import threading
import weakref
from test import support
from threading import Thread
from unittest import TestCase

Expand Down Expand Up @@ -58,6 +61,43 @@ def runner():
with threading_helper.start_threads(threads):
pass

def test_all_tasks_different_thread(self) -> None:
task = None
loop = None
started = threading.Event()
stop = threading.Event()
done = False
async def func():
nonlocal task, loop, done
loop = asyncio.get_running_loop()
task = asyncio.current_task()
started.set()
while not stop.is_set():
await asyncio.sleep(0)

thread = Thread(target=lambda: asyncio.run(func()))
with threading_helper.start_threads([thread]):
started.wait()
self.assertSetEqual(asyncio.all_tasks(loop), {task})
self.assertIs(task.get_loop(), loop)
stop.set()

def test_all_tasks_different_thread_finalized(self) -> None:
task = None
loop = asyncio.EventLoop()
async def func():
nonlocal task
task = asyncio.current_task()

loop.run_until_complete(func())

self.assertEqual(self.all_tasks(loop), set())
wr = weakref.ref(task)
del task
# task finalization in different thread shoudn't crash
support.gc_collect()
self.assertIsNone(wr())

def test_run_coroutine_threadsafe(self) -> None:
results = []

Expand Down
Loading