future_safe & RuntimeWarning: coroutine '...' was never awaited
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với FutureResultE.from_iterable và ví dụ tối thiểu trong issue, sau đó kiểm tra returns/_generated/futures/_future_result.py:44 và returns/future.py:594, nơi các cảnh báo xuất hiện. Tái hiện với Python 3.7 và ví dụ timeout bị lỗi; được xem là hoàn tất khi Failure dự kiến vẫn còn, trong khi các RuntimeWarnings unawaited-coroutine không còn xuất hiện.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi!
I'm running sample code from https://returns.readthedocs.io/en/latest/pages/future.html#futureresult on python3.7
I've set timeout for AsyncClient to 0.01, expecting the function to always fail. That works correct, the result is <IOResult: <Failure: >>
But there are lots of RuntimeWarnings:
/.../returns/_generated/futures/_future_result.py:44: RuntimeWarning: coroutine 'async_map' was never awaited
container = await inner_value
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/.../returns/_generated/futures/_future_result.py:44: RuntimeWarning: coroutine 'future_safe.<locals>.factory' was never awaited
container = await inner_value
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/.../future.py:594: RuntimeWarning: coroutine 'async_map' was never awaited
return IOResult.from_result(await self._inner_value)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/.../returns/future.py:594: RuntimeWarning: coroutine 'future_safe.<locals>.factory' was never awaited
return IOResult.from_result(await self._inner_value)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
It is not a good idea to disable RuntimeWarnings, and i suspect this behaviour to be incorrect.
I think that the problem is inside the FutureResultE.from_iterable, the minimal working example is like this:
@future_safe
async def f1(x: float) -> float:
return x / 0
def f2() -> FutureResultE[Sequence[float]]:
return FutureResultE.from_iterable(
# changing range(3) -> range(1) removes RuntimeWarnings
[f1(x).map(lambda k: k + 1) for x in range(3)]
)
print(anyio.run(f2().awaitable))
- 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
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dry-python/returns
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
dry-python/returns#2394 · 1 reaction ·
-
Composing 0-argument functions Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
dry-python/returns#2365 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
dry-python/returns#2355 · 1 bình luận ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
dry-python/returns#2295 · 4 bình luận · 1 reaction ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
dry-python/returns#2253 · 2 bình luận ·
Tất cả issue của dry-python/returns
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
canonical/paas-charm#368 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
tech debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
addition to tracking list Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
StevenBlack/hosts#3256 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
qualcomm/qai-appbuilder#275 ·