Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

ReAwaitable does not support concurrent await call

未关闭
#2,108 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
backend

调研方向

首先分别针对 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 help wanted

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

  • returns version: 0.25.0
  • pytest version (if any): 8.3.4
主要语言
Python
星标
4.4k
派生
154
平均合并
3 小时 5 分钟
30 天内合并 PR
22

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dry-python/returns 的其他 Issue

查看 dry-python/returns 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。