future_safe & RuntimeWarning: coroutine '...' was never awaited
まだ誰も着手していません。
評価
調査の方向性
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
- フォーク
- 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
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
learningequality/ricecooker#747 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
run-llama/llama_index#23199 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
KhronosGroup/glTF-Blender-IO#2769 ·