future_safe & RuntimeWarning: coroutine '...' was never awaited
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 FutureResultE.from_iterable 和 issue 中的最小範例開始,接著檢查出現警告的 returns/_generated/futures/_future_result.py:44 和 returns/future.py:594。使用 Python 3.7 和失敗的 timeout 範例重現;當預期的 Failure 仍然存在,同時不再出現 unawaited-coroutine RuntimeWarnings 時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
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))
- 主要語言
- Python
- 星號
- 4.4k
- 分支
- 156
- 平均合併
- 3 小時 44 分鐘
- 30 天內合併 PR
- 22
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
dry-python/returns 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 48/100
dry-python/returns#2394 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 52/100
dry-python/returns#2365 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 25/100
dry-python/returns#2355 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 45/100
dry-python/returns#2295 · 4 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 45/100
dry-python/returns#2253 · 2 則留言 ·
維護者通常 1 天內回覆
查看 dry-python/returns 的全部 Issue
相似的 Issue
-
namespace operations
難度 1/5 1 小時以內 新手友好度 72/100
EclipseFdn/open-vsx.org#14043 ·
維護者通常 1 天內回覆
-
netbox status: needs triage type: bug
難度 2/5 1-3 小時 新手友好度 76/100
netbox-community/netbox#23376 ·
維護者通常 1 天內回覆
-
feedback simulation workshop
難度 2/5 1-3 小時 新手友好度 73/100
githubnext/gh-aw-workshop#4455 ·
維護者通常 1 天內回覆
-
Triage 🩺
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_wait未關閉needs-triage
難度 2/5 1-3 小時 新手友好度 77/100
krkn-chaos/krkn#1627 · 1 則留言 ·
維護者通常 1 天內回覆