Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#565 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Inizia da FutureResultE.from_iterable e dall’esempio minimo nell’issue, quindi esamina returns/_generated/futures/_future_result.py:44 e returns/future.py:594, dove si verificano gli avvisi. Riproduci il problema con Python 3.7 e l’esempio di timeout che fallisce; il lavoro è completato quando il Failure previsto rimane, mentre i RuntimeWarnings unawaited-coroutine non compaiono più.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug help wanted

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))
Lingua principale
Python
Stelle
4.4k
Fork
154
Merge medio
3h 5m
PR unite (30g)
22

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dry-python/returns

Tutte le issue di dry-python/returns

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.