From 204c3fd59ffeab656237c4d904eaead58fc85559 Mon Sep 17 00:00:00 2001
From: Platon Pronko <platon7pronko@gmail.com>
Date: Thu, 5 Feb 2026 15:06:18 +0400
Subject: [PATCH] create a new asyncio loop

In newer Python versions asyncio does not create the loop automatically,
we have to update it manually.
https://github.com/jlebon/textern/pull/97
---
 native/textern.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/native/textern.py b/native/textern.py
index b1b80bd..c182bae 100755
--- a/native/textern.py
+++ b/native/textern.py
@@ -100,20 +100,19 @@ def get(self, relfn):
 def main():
     with INotify() as ino, TmpManager() as tmp_mgr:
         ino.add_watch(tmp_mgr.tmpdir, flags.CLOSE_WRITE)
-        loop = asyncio.get_event_loop()
-        loop.add_reader(sys.stdin.buffer, handle_stdin, tmp_mgr)
+        loop = asyncio.new_event_loop()
+        loop.add_reader(sys.stdin.buffer, handle_stdin, tmp_mgr, loop)
         loop.add_reader(ino.fd, handle_inotify_event, ino, tmp_mgr)
         loop.run_forever()
         loop.close()
 
 
-def handle_stdin(tmp_mgr):
+def handle_stdin(tmp_mgr, loop):
     # In theory, these reads could block, since we only know that there is some
     # data, but not that all the data is there. We could be more strict here by
     # reading in a separate thread. In practice, we're trusting that we're
     # talking with Firefox and that readiness implies a full message (length +
     # content) is ready to be read.
-    loop = asyncio.get_event_loop()
     raw_length = sys.stdin.buffer.read(4)
     if len(raw_length) == 0:
         loop.stop()
