Skip to content

fix: removed uvloop entirely - #520

Open
JinIgarashi wants to merge 2 commits into
UNDP-Data:mainfrom
JinIgarashi:fix/519-set-event-loop
Open

fix: removed uvloop entirely#520
JinIgarashi wants to merge 2 commits into
UNDP-Data:mainfrom
JinIgarashi:fix/519-set-event-loop

Conversation

@JinIgarashi

@JinIgarashi JinIgarashi commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

fixes #519 RuntimeError: There is no current event loop in sync component code paths

Problem

rapida assess -c population crashes immediately:

File "/rapida/rapida/components/population/init.py", line 387, in download_compute
downloaded_files = asyncio.run(download_remote_files(...))
File ".../uvloop/init.py", line 206, in get_event_loop
raise RuntimeError(
RuntimeError: There is no current event loop in thread 'MainThread'.
sys:1: RuntimeWarning: coroutine 'download_remote_files' was never awaited

Cause

The asyncio bootstrap in rapida/cli/__init__.py:

  • nest_asyncio.apply() replaces asyncio.run with a version that reuses the current loop via get_event_loop() — it never creates one itself.
  • The uvloop policy installed right after it raises RuntimeError instead of implicitly creating a loop (uvloop 0.22 behaviour).
  • assess is a synchronous Click command, so there is neither a running loop nor a registered one, and every asyncio.run(...) on a sync path fails.

Fix

remove uvloop entirely

- asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

@JinIgarashi JinIgarashi changed the title fix: create and register a current uvloop loop after the policy is installed fix: removed uvloop entirely Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

population component failed

1 participant