Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit156778d

Browse files
authored
Fix AsyncRunner failure on Python 3.14 due to asyncio.get_event_loop() removal (#490)
1 parentbe769d8 commit156778d

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

‎.github/workflows/nox.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fail-fast:false
1313
matrix:
1414
platform:[ubuntu-latest, macos-latest, windows-latest]
15-
python-version:["3.11", "3.12", "3.13"]
15+
python-version:["3.11", "3.12", "3.13", "3.14"]
1616

1717
steps:
1818
-uses:actions/checkout@v4

‎adaptive/runner.py‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ def __init__(
626626
raise_if_retries_exceeded=raise_if_retries_exceeded,
627627
allow_running_forever=True,
628628
)
629-
self.ioloop=iolooporasyncio.get_event_loop()
629+
self.ioloop=ioloopifioloopisnotNoneelse_get_or_create_event_loop()
630630

631631
# When the learned function is 'async def', we run it
632632
# directly on the event loop, and not in the executor.
@@ -987,7 +987,22 @@ def replay_log(
987987
getattr(learner,method)(*args)
988988

989989

990-
# -- Internal executor-related, things
990+
# -- Internal executor-related things
991+
992+
993+
def_get_or_create_event_loop()->asyncio.AbstractEventLoop:
994+
"""Get the running event loop or create a new one.
995+
996+
In Python 3.10+, asyncio.get_event_loop() is deprecated when no loop is running.
997+
In Python 3.14+, it raises RuntimeError instead of creating a new loop.
998+
This function provides a compatible way to get or create an event loop.
999+
"""
1000+
try:
1001+
returnasyncio.get_running_loop()
1002+
exceptRuntimeError:
1003+
loop=asyncio.new_event_loop()
1004+
asyncio.set_event_loop(loop)
1005+
returnloop
9911006

9921007

9931008
def_ensure_executor(executor:ExecutorTypes|None)->concurrent.Executor:

‎noxfile.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
nox.options.default_venv_backend="uv"
88

9-
python= ["3.11","3.12","3.13"]
9+
python= ["3.11","3.12","3.13","3.14"]
1010
num_cpus=os.cpu_count()or1
1111
xdist= ("-n","auto")ifnum_cpus>2else ()
1212

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ classifiers = [
1616
"Programming Language :: Python :: 3.11",
1717
"Programming Language :: Python :: 3.12",
1818
"Programming Language :: Python :: 3.13",
19+
"Programming Language :: Python :: 3.14",
1920
]
2021
dependencies = [
2122
"scipy",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp