batou icon indicating copy to clipboard operation
batou copied to clipboard

Make compatible with Python 3.14

Open wosc opened this issue 2 months ago • 0 comments

Traceback (most recent call last):
File "lib/python3.14/site-packages/batou/deploy.py", line 228, in main
  step()
  ~~~~^^
File "lib/python3.14/site-packages/batou/deploy.py", line 178, in deploy
  self.loop = asyncio.get_event_loop()
              ~~~~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/[email protected]/3.14.0/Frameworks/Python.framework/Versions/3.14/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'.

I must confess I'm not up-to-date on asyncio APIs, but this patch seems to fix it on 3.14 -- no clue if that's correct, and how far that's backwards-compatible, though.

--- src/batou/deploy.py
+++ src/batou/deploy.py
-       self.loop = asyncio.get_event_loop()
+       self.loop = asyncio.new_event_loop()
+       asyncio.set_event_loop(self.loop)

wosc avatar Oct 17 '25 12:10 wosc