Skip to content

fix: create event-loop on Python 3.14 where get_event_loop raises - #314

Merged
r00ta merged 1 commit into
canonical:masterfrom
hemanthnakkina:fix/asyncio-314-event-loop
Dec 1, 2026
Merged

r00ta merged 1 commit into
canonical:masterfrom
hemanthnakkina:fix/asyncio-314-event-loop

Conversation

@hemanthnakkina

Copy link
Copy Markdown
Contributor

Python 3.14 removed implicit event-loop creation in the main thread; asyncio.get_event_loop() now raises RuntimeError when no loop is set. Wrap loop lookup in _get_or_create_event_loop() so synchronous use of the client (Asynchronous metaclass, is_loop_running) keeps working: fall back to creating and setting a new loop, matching the behaviour of Python <= 3.12.

Python 3.14 removed implicit event-loop creation in the main thread;
asyncio.get_event_loop() now raises RuntimeError when no loop is set.
Wrap loop lookup in _get_or_create_event_loop() so synchronous use of
the client (Asynchronous metaclass, is_loop_running) keeps working:
fall back to creating and setting a new loop, matching the behaviour
of Python <= 3.12.
hemanthnakkina added a commit to hemanthnakkina/snap-openstack that referenced this pull request Nov 30, 2026
Lock python-libmaas to the revision from canonical/python-libmaas#314
while the fix is pending. This restores synchronous calls made before
an asyncio event loop has been set.
@hemanthnakkina

Copy link
Copy Markdown
Contributor Author

@r00ta I see CI builds not started for more than 18 hours. Are these runners from github? Is it makes sense to cancel the workflow and rerun them?

hemanthnakkina added a commit to canonical/snap-openstack that referenced this pull request Dec 1, 2026
Pin the branch carrying the async event-loop fix from
canonical/python-libmaas#314 and update the lockfile.

Signed-off-by: Hemanth Nakkina <hemanth.nakkina@canonical.com>
@r00ta
r00ta merged commit e689368 into canonical:master Dec 1, 2026
1 of 7 checks passed
gboutry pushed a commit to canonical/snap-openstack that referenced this pull request Dec 2, 2026
python-libmaas was previously pinned to a personal fork commit.
PR #314 [1] has been merged upstream, so point to
canonical/python-libmaas at the merge commit e689368e instead.

[1] canonical/python-libmaas#314
victorsantos-baires added a commit to victorsantos-baires/snap-openstack that referenced this pull request Dec 3, 2026
python-libmaas 0.6.8 from PyPI calls asyncio.get_event_loop() with
no running loop, which raises RuntimeError on Python 3.14. On the
core26 snap, `sunbeam deployment add maas` fails with "There is no
current event loop in thread 'MainThread'".

Pin canonical/python-libmaas at the merge commit of the fix [1], as
done on stable/2026.1 in canonical#1065, and update the lockfile.

[1] canonical/python-libmaas#314

Closes-Bug: #2180159
Signed-off-by: victor.santos <victor.santos@canonical.com>
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.

2 participants