ReAwaitable does not support concurrent await call
还没有人认领这个 Issue。
评估
调研方向
首先分别针对 trio 和 asyncio 情况运行 tests/test_primitives/test_reawaitable/test_reawaitable_concurrency.py。阅读 project/primitives/reawaitable.py 第 109 行附近 coroutine 被 await 的位置,并将其行为与并发 task 场景进行比较。当多个同时运行的 task 可以 await ReAwaitable 且不会产生报告中的 RuntimeError 时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Bug report
What's wrong
ReAwaitable cannot be awaited from multiple asyncio tasks simultaneously, and raises exception.
<user>/Library/Caches/pypoetry/virtualenvs/project-env/bin/python /Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py --target test_reawaitable_concurrency.py::test_concurrent_awaitable
Testing started at 16:14 ...
Launching pytest with arguments test_reawaitable_concurrency.py::test_concurrent_awaitable --no-header --no-summary -q in <user>/repos/project/tests/test_primitives/test_reawaitable
============================= test session starts ==============================
collecting ... collected 2 items
Running 2 items in this shard: tests/test_primitives/test_reawaitable/test_reawaitable_concurrency.py::test_concurrent_awaitable[trio], tests/test_primitives/test_reawaitable/test_reawaitable_concurrency.py::test_concurrent_awaitable[asyncio]
test_reawaitable_concurrency.py::test_concurrent_awaitable[trio]
test_reawaitable_concurrency.py::test_concurrent_awaitable[asyncio] <user>/Library/Caches/pypoetry/virtualenvs/project-env/lib/python3.12/site-packages/coverage/inorout.py:524: CoverageWarning: Module project was previously imported, but not measured (module-not-measured)
self.warn(msg, slug="module-not-measured")
ERROR: Coverage failure: total of 1 is less than fail-under=100
============================== 2 failed in 1.29s ===============================
FAILED [ 50%]
tests/test_primitives/test_reawaitable/test_reawaitable_concurrency.py:10 (test_concurrent_awaitable[trio])
+ Exception Group Traceback (most recent call last):
| File "<user>/Library/Caches/pypoetry/virtualenvs/project-env/lib/python3.12/site-packages/_pytest/runner.py", line 341, in from_call
| result: TResult | None = func()
| ^^^^^^
[...multiple frames omitted for brevity...]
| File "<user>/repos/project/tests/test_primitives/test_reawaitable/test_reawaitable_concurrency.py", line 17, in test_concurrent_awaitable
| async with anyio.create_task_group() as tg:
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| File "<user>/Library/Caches/pypoetry/virtualenvs/project-env/lib/python3.12/site-packages/anyio/_backends/_trio.py", line 191, in __aexit__
| return await self._nursery_manager.__aexit__(exc_type, exc_val, exc_tb)
| ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "<user>/repos/project/tests/test_primitives/test_reawaitable/test_reawaitable_concurrency.py", line 16, in await_reawaitable
| return await reawaitable
| ^^^^^^^^^^^^^^^^^
| File "<user>/repos/project/project/primitives/reawaitable.py", line 109, in _awaitable
| self._cache = await self._coro
| ^^^^^^^^^^^^^^^^
| RuntimeError: coroutine is being awaited already
+------------------------------------
FAILED [100%]
[... similar traceback omitted for brevity ...]
<user>/Library/Caches/pypoetry/virtualenvs/project-env/lib/python3.12/site-packages/pytest_cov/plugin.py:355: CovFailUnderWarning: Coverage failure: total of 1 is less than fail-under=100
warnings.warn(CovFailUnderWarning(message), stacklevel=1)
How is that should be
ReAwaitable should be awaitable from multiple simultaneous tasks.
System information
returnsversion: 0.25.0pytestversion (if any): 8.3.4
- 主要语言
- Python
- 星标
- 4.4k
- 派生
- 154
- 平均合并
- 3 小时 5 分钟
- 30 天内合并 PR
- 22
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dry-python/returns 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 48/100
dry-python/returns#2394 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 52/100
dry-python/returns#2365 ·
-
难度 5/5 一周以上 新手友好度 25/100
dry-python/returns#2355 · 1 条评论 ·
-
bug
难度 4/5 3-5 天 新手友好度 45/100
dry-python/returns#2295 · 4 条评论 · 1 个 reaction ·
-
bug
难度 4/5 3-5 天 新手友好度 45/100
dry-python/returns#2253 · 2 条评论 ·
查看 dry-python/returns 的全部 Issue
相似的 Issue
-
area: harness bug status: needs-triage
难度 2/5 1-3 小时 新手友好度 75/100
Human-Agent-Society/reef#625 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 1/5 1 小时以内 新手友好度 80/100
learningequality/kolibri#15351 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
Name consistency 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
eellak/triplestore#65 · 1 条评论 ·