Skip to content

Commit d85785d

Browse files
authored
fix: add support for Python 3.14 (#196)
1 parent 4d792e0 commit d85785d

5 files changed

Lines changed: 32 additions & 4 deletions

File tree

.audit/python314

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## AI Assistance Disclosure
2+
3+
- [x] I did **not** use AI-assisted tools to help create this pull request.
4+
- [ ] I used AI-assisted tools to help create this pull request.
5+
6+
- [x] I have read, understood and followed the projects' [AI Policy](../AI_POLICY.rst) when creating this pull request.
7+
8+
Submitted by: @Jenselme
9+
Date: 2025-09-03
10+
Related issue(s): #193
11+
Branch: python314

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
os: [ubuntu-24.04]
3636

3737
# https://github.com/actions/setup-python#specifying-a-pypy-version
38-
python-version: ['3.10', '3.12', 'pypy-3.10']
38+
python-version: ['3.10', '3.12', '3.14', 'pypy-3.10']
3939

4040
# https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/
4141
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error

test/util.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def run_once():
4747
from _asyncio_test_utils import run_once as _run_once
4848
else:
4949
from asyncio.test_utils import run_once as _run_once
50-
return _run_once(txaio.config.loop or asyncio.get_event_loop())
50+
return _run_once(txaio.config.loop or _get_loop())
5151

5252
except ImportError:
5353
import trollius as asyncio
@@ -66,6 +66,16 @@ def run_once():
6666
asyncio.gather(*asyncio.Task.all_tasks())
6767

6868

69+
def _get_loop():
70+
import asyncio
71+
try:
72+
return asyncio.get_event_loop()
73+
except RuntimeError:
74+
loop = asyncio.new_event_loop()
75+
asyncio.set_event_loop(loop)
76+
return loop
77+
78+
6979
def _await(future):
7080
"""
7181
Essentially just a way to call "run_until_complete" that becomes a

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ envlist =
44
flake8
55
py310-{tw2210,tw255,twtrunk,asyncio}
66
py312-{tw2210,tw255,twtrunk,asyncio}
7+
py314-{tw2210,tw255,twtrunk,asyncio}
78
pypy310-{tw2210,tw255,twtrunk,asyncio}
89

910
# Python 3.11.11 (0253c85bf5f8, Feb 26 2025, 10:42:42)
@@ -21,12 +22,13 @@ envlist =
2122
python =
2223
3.10: py310
2324
3.12: py312
25+
3.14: py314
2426
pypy-3.10: pypy310
2527

2628

2729
[testenv]
2830
deps =
29-
pytest==7.2.1
31+
pytest==8.4.0
3032
coverage==7.0.5
3133
tw2210: twisted==22.10.0
3234
tw255: twisted==25.5.0

txaio/aio.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,12 @@ def _loop(self):
321321
# otherwise give out the event loop of the thread this is called in
322322
# rather fetching the loop once in __init__, which may not neccessarily
323323
# be called from the thread we now run the event loop in.
324-
return asyncio.get_event_loop()
324+
try:
325+
return asyncio.get_event_loop()
326+
except RuntimeError:
327+
loop = asyncio.new_event_loop()
328+
asyncio.set_event_loop(loop)
329+
return loop
325330

326331
def failure_message(self, fail):
327332
"""

0 commit comments

Comments
 (0)