acoustic-carpenter-78188
03/13/2026, 4:55 PMRuntimeError: Cannot run the event loop while another loop is running when FlyteRemote.execute() is called from within an already-running async event loop (e.g., Flask with Gunicorn)
• _AsyncLoopManager.run_sync() now detects a running loop and spawns a short-lived thread with its own event loop via asyncio.run(), preserving context variables with contextvars.copy_context()
• The original _TaskRunner path remains unchanged for non-async contexts
Test plan
• Added test_run_sync_from_running_event_loop — verifies run_sync works when called from within a running event loop
• Added test_run_sync_from_running_event_loop_with_exception — verifies exceptions propagate correctly in this path
• All existing tests in tests/flytekit/unit/utils/test_asyn.py pass (8/8)
flyteorg/flytekit