ReAwaitable does not support concurrent await call
まだ誰も着手していません。
評価
調査の方向性
まず、trio と asyncio の両方のケースで tests/test_primitives/test_reawaitable/test_reawaitable_concurrency.py を実行します。コルーチンが await される project/primitives/reawaitable.py の 109 行目付近を読み、並行タスクのシナリオと挙動を比較します。複数の同時実行タスクが、報告されている RuntimeError を発生させずに ReAwaitable を await できれば完了です。
索引モデルが 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分
- マージ済み PR(30日)
- 22
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dry-python/returns のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
dry-python/returns#2394 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
dry-python/returns#2365 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
dry-python/returns#2355 · コメント 1 件 ·
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
dry-python/returns#2295 · コメント 4 件 · リアクション 1 件 ·
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
dry-python/returns#2253 · コメント 2 件 ·
dry-python/returns の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
anthropics/skills#1811 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
speaches-ai/speaches#678 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
datalayer/mcp-compose#42 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
conda-forge/spacy-feedstock#177 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
UKGovernmentBEIS/inspect_evals#2523 ·