acoustic-carpenter-78188
08/01/2026, 9:02 AMflyte.map / flyte.map.aio yields un-awaited coroutines in local mode
Issue created by flabbergastedbd
Summary
In local mode, flyte.map(...) and flyte.map.aio(...) yield bare, un-awaited coroutines rather than task results. The remote branch awaits correctly via `MapAsyncIterator._invoke`; the local branch does not.
Reproduction
import flyte
env = flyte.TaskEnvironment(name="probe")
@env.task
async def echo(x: str) -> str:
return f"echo:{x}"
@env.task
async def parent() -> list[str]:
out = []
async for r in flyte.map.aio(echo, ["a", "b", "c"], concurrency=0, return_exceptions=False):
out.append(r)
print("type:", type(r).name, "value:", r)
return [str(o) for o in out]
if name == "__main__":
result = flyte.with_runcontext(mode="local").run(parent)
print(result.outputs())
Observed (flyte==2.5.16, Python 3.12, clean venv)
RuntimeWarning: coroutine 'LocalController.submit' was never awaited
type: coroutine value: <coroutine object LocalController.submit at 0x...>
type: coroutine value: <coroutine object LocalController.submit at 0x...>
type: coroutine value: <coroutine object LocalController.submit at 0x...>
ActionOutputs(o0=['<coroutine object LocalController.submit at 0x...>', ...])
Expected
Local mode should await each subtask and yield resolved results, matching the remote branch. If local-mode map is intentionally unsupported, calling it should raise a clear error rather than silently emitting un-awaited coroutines.
Root cause
src/flyte/_map.py — both _Mapper.__call__ and _Mapper.aio have this local branch:
if not tctx or tctx.mode == "local":
logger.warning("Running map in local mode, which will run every task sequentially.")
for v in zip(*args):
try:
yield func(*v) # returns a coroutine; never awaited
except Exception as e:
...
The remote branch dispatches through MapAsyncIterator._invoke which does await self.func.aio(*arg_tuple). The local branch is missing the equivalent await ... .aio(...).
Environment
• flyte SDK: 2.5.16 (also reproduces on `2.2.2`; unchanged on main)
• Python: 3.12
flyteorg/flyte-sdkacoustic-carpenter-78188
08/03/2026, 5:57 PMflyte.map / flyte.map.aio yields un-awaited coroutines in local mode
Issue closed as completed by cosmicBboy
flyteorg/flyte-sdk