[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread Łukasz Langa
Łukasz Langa added the comment: Thanks, Thomas! ✨  ✨ -- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: +Python 3.11 -Python 3.7, Python 3.8 ___ Python tracker

[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread Łukasz Langa
Łukasz Langa added the comment: New changeset 166ad706066a2aad84d0ae5b1594c88904fbb939 by Miss Islington (bot) in branch '3.9': bpo-44962: Fix a race in WeakKeyDict, WeakValueDict and WeakSet when two threads attempt to commit the last pending removal (GH-27921) (GH-28014)

[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread miss-islington
miss-islington added the comment: New changeset 8aa64cc45bff516a6db1f3a3c037cbcce9417fea by Miss Islington (bot) in branch '3.10': bpo-44962: Fix a race in WeakKeyDict, WeakValueDict and WeakSet when two threads attempt to commit the last pending removal (GH-27921)

[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread miss-islington
Change by miss-islington : -- pull_requests: +26457 pull_request: https://github.com/python/cpython/pull/28014 ___ Python tracker ___

[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 5.0 -> 6.0 pull_requests: +26456 pull_request: https://github.com/python/cpython/pull/28013 ___ Python tracker

[issue44962] asyncio.create_task weakrefset race condition

2021-08-28 Thread Łukasz Langa
Łukasz Langa added the comment: New changeset 206b21ed9f64fedff67bfea7cf73e423e3e32393 by Thomas Grainger in branch 'main': bpo-44962: Fix a race in WeakKeyDict, WeakValueDict and WeakSet when two threads attempt to commit the last pending removal (GH-27921)

[issue44962] asyncio.create_task weakrefset race condition

2021-08-24 Thread Thomas Grainger
Change by Thomas Grainger : -- nosy: +pitrou ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44962] asyncio.create_task weakrefset race condition

2021-08-23 Thread Thomas Grainger
Thomas Grainger added the comment: > weakref.WeakSet is not thread-safe, which means concurrent create_task's in > different threads (even on separate event loops) is not safe. actually it looks like WeakSet is *supposed* to be thread-safe ``` import patchy patchy.patch(

[issue44962] asyncio.create_task weakrefset race condition

2021-08-23 Thread Thomas Grainger
Change by Thomas Grainger : -- pull_requests: +26373 pull_request: https://github.com/python/cpython/pull/27921 ___ Python tracker ___

[issue44962] asyncio.create_task weakrefset race condition

2021-08-23 Thread Thomas Grainger
Change by Thomas Grainger : -- keywords: +patch pull_requests: +26365 stage: -> patch review pull_request: https://github.com/python/cpython/pull/27909 ___ Python tracker ___

[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Ben
Ben added the comment: I can reproduce on 3.9.6 A little digging and it seems asyncio imports Task from _asyncio and _asyncio's implementation (in asynciomodule.c) of Task has an __init__ which adds the task to the `all_tasks` weakref.WeakSet which appears to be implemented in Python (in

[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Thomas Grainger
Thomas Grainger added the comment: interestingly 3.10 didn't show: sys:1: RuntimeWarning: coroutine 'BaseEventLoop.shutdown_asyncgens' was never awaited -- ___ Python tracker

[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Thomas Grainger
Thomas Grainger added the comment: still happens on 3.10 even though there's an `with _IterationGuard` ``` worked 0 Traceback (most recent call last): File "/home/graingert/projects/asyncio-demo/demo.py", line 36, in sys.exit(main()) File

[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Thomas Grainger
Change by Thomas Grainger : -- versions: +Python 3.10 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Thomas Grainger
Change by Thomas Grainger : -- versions: +Python 3.7 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44962] asyncio.create_task weakrefset race condition

2021-08-20 Thread Thomas Grainger
New submission from Thomas Grainger : with the following demo script I can get a IndexError: pop from empty list ``` import itertools import asyncio import concurrent.futures import sys import threading threads = 200 def test_all_tasks_threading() -> None: async def foo() -> None: