Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

ReAwaitable does not support concurrent await call

Đang mở
#2,108 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu bằng cách chạy tests/test_primitives/test_reawaitable/test_reawaitable_concurrency.py cho cả trường hợp trio và asyncio. Đọc project/primitives/reawaitable.py quanh dòng 109, nơi coroutine được await, và so sánh hành vi với kịch bản các task chạy đồng thời. Được xem là hoàn tất khi ReAwaitable có thể được nhiều task đồng thời await mà không phát sinh RuntimeError đã được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Python
Star
4.4k
Fork
154
Merge trung bình
3 giờ 5 phút
Pull request đã merge (30 ngày)
22

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dry-python/returns

Tất cả issue của dry-python/returns

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.