Conversation
| loop = asyncio.new_event_loop() | ||
| asyncio.set_event_loop(loop) | ||
|
|
||
| loop = asyncio.get_event_loop() |
There was a problem hiding this comment.
Ah. my bad, will fix and repush.
There was a problem hiding this comment.
I reworked the patch to check the python version instead of catching exception.
There was a problem hiding this comment.
AFAICT, the new_event_loop/set_event_loop APIs have been around for a long time now. So I think instead of doing a version comparison, we could just unconditionally always create an event loop and set it. We should also then be able to get rid of the get_event_loop call below.
Hit following traceback on system with Python 3.14:
```
stderr output from native app textern: Traceback (most recent call last):
stderr output from native app textern: File "/home/igyn/.local/libexec/textern/textern.py", line 246, in <module>
stderr output from native app textern: sys.exit(main())
stderr output from native app textern: ~~~~^^
stderr output from native app textern: File "/home/igyn/.local/libexec/textern/textern.py", line 103, in main
stderr output from native app textern: loop = asyncio.get_event_loop()
stderr output from native app textern: File "/usr/lib64/python3.14/asyncio/events.py", line 715, in get_event_loop
stderr output from native app textern: raise RuntimeError('There is no current event loop in thread %r.'
stderr output from native app textern: % threading.current_thread().name)
stderr output from native app textern: RuntimeError: There is no current event loop in thread 'MainThread'.
```
This error is caused by a significant change in Python 3.14. In this version,
asyncio.get_event_loop() no longer creates a new event loop automatically if
one doesn't exist; instead, it raises the RuntimeError.
The code was updated to create an event loop if running on Python 3.14 or higher.
Assisted-by: Gemini3 (Fast)
Signed-off-by: Jan Tluka <[email protected]>
eb5d50f to
ae7faf8
Compare
|
I have tested this. It fixes textern for me. Thank you! |
jlebon
left a comment
There was a problem hiding this comment.
Sorry for the long delays here. Your reply slipped by.
In truth, I haven't been using Textern myself in a while because I switched to flatpak for my Firefox and it's a pain right now to set up native apps for it in a safe way. I'm working in the background on tweaking Textern to make it more palatable.
| loop = asyncio.new_event_loop() | ||
| asyncio.set_event_loop(loop) | ||
|
|
||
| loop = asyncio.get_event_loop() |
There was a problem hiding this comment.
AFAICT, the new_event_loop/set_event_loop APIs have been around for a long time now. So I think instead of doing a version comparison, we could just unconditionally always create an event loop and set it. We should also then be able to get rid of the get_event_loop call below.
In newer Python versions asyncio does not create the loop automatically, we have to update it manually. jlebon#97
Hit following traceback on system with Python 3.14:
This error is caused by a significant change in Python 3.14. In this version, asyncio.get_event_loop() no longer creates a new event loop automatically if one doesn't exist; instead, it raises the RuntimeError.
The code was updated to catch the exception and create the event loop if necessary.
Assisted-by: Gemini3 (Fast)