dry-python / dry-python/returns

future_safe & RuntimeWarning: coroutine '...' was never awaited

Đang mở
#565 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug help wanted
Ngôn ngữ chính
Python
Star
4.4k
Fork
155
Merge trung bình
2 giờ 27 phút
Pull request đã merge (30 ngày)
22

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 >
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..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..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))
```

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

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

Đánh giá

Issue này chưa được đánh giá.

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.