-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
After upgrading to Python 3.14, running any aiocli command fails with the following error:
Traceback (most recent call last):
...
File "aiocli/commander.py", line 143, in wrapper
loop_ = loop or get_event_loop()
~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.14/asyncio/events.py", line 715, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
% threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'MainThread'.This happens because Python 3.14 removed implicit event loop creation (see PEP 719), so asyncio.get_event_loop() now raises RuntimeError when called outside a running loop.
Expected Behavior
aiocli should automatically create an event loop if none exists, maintaining backward compatibility with Python ≤3.13.
Actual Behavior
RuntimeError: There is no current event loop in thread 'MainThread'.
Suggested Fix
Wrap the call in aiocli/commander.py with safe event loop initialization:
import asyncio
def get_safe_event_loop():
try:
return asyncio.get_running_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
return loopThen replace:
loop_ = loop or get_event_loop()with:
loop_ = loop or get_safe_event_loop()Additional Notes
Also seeing a warning from pyparsing under Python 3.14:
SyntaxWarning: 'return' in a 'finally' block(probably unrelated, just noticed in the same run).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working