8000 gh-128002: use `_PyObject_SetMaybeWeakref` when creating tasks in asyncio by kumaraditya303 · Pull Request #128885 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-128002: use _PyObject_SetMaybeWeakref when creating tasks in asyncio #128885

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

Merged
merged 5 commits into from
Jan 24, 2025
Merged
Changes from 1 commit
Commits
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
use a less strict test
  • Loading branch information
kumaraditya303 committed Jan 24, 2025
commit ede0c4945e9202354722af6f41ed7ec10e7d6f9c
8 changes: 4 additions & 4 deletions Lib/test/test_asyncio/test_free_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ async def coro():
await asyncio.sleep(0.01)

lock = threading.Lock()
count = 0
tasks = set()

async def main():
nonlocal count, loop
nonlocal tasks, loop
loop = asyncio.get_running_loop()
started.set()
for i in range(1000):
with lock:
asyncio.create_task(coro())
count = len(self.all_tasks(loop))
tasks = self.all_tasks(loop)

runner = threading.Thread(target=lambda: asyncio.run(main()))

def check():
started.wait()
with lock:
self.assertEqual(count, len(self.all_tasks(loop)))
self.assertSetEqual(tasks & self.all_tasks(loop), tasks)

threads = [threading.Thread(target=check) for _ in range(10)]
threads.append(runner)
Expand Down
Loading
0