File: python3.14-create-event-loop-if-not-exists.patch

package info (click to toggle)
python-txaio 25.6.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 576 kB
  • sloc: python: 2,477; makefile: 226; sh: 48
file content (22 lines) | stat: -rw-r--r-- 829 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Description: Python 3.14: create event loop if not exists
Author: Thomas Goirand <zigo@debian.org>
Bug-Debian: https://bugs.debian.org/1125125
Forwarded: no
Last-Update: 2026-01-12

--- python-txaio-25.6.1.orig/txaio/aio.py
+++ python-txaio-25.6.1/txaio/aio.py
@@ -321,7 +321,12 @@ class _AsyncioApi(object):
         # otherwise give out the event loop of the thread this is called in
         # rather fetching the loop once in __init__, which may not neccessarily
         # be called from the thread we now run the event loop in.
-        return asyncio.get_event_loop()
+        try:
+            return asyncio.get_event_loop()
+        except RuntimeError:
+            loop = asyncio.new_event_loop()
+            asyncio.set_event_loop(loop)
+            return loop
 
     def failure_message(self, fail):
         """