Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]
python-version: ["3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4
Expand Down
19 changes: 17 additions & 2 deletions adaptive/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ def __init__(
raise_if_retries_exceeded=raise_if_retries_exceeded,
allow_running_forever=True,
)
self.ioloop = ioloop or asyncio.get_event_loop()
self.ioloop = ioloop if ioloop is not None else _get_or_create_event_loop()

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


# -- Internal executor-related, things
# -- Internal executor-related things


def _get_or_create_event_loop() -> asyncio.AbstractEventLoop:
"""Get the running event loop or create a new one.
In Python 3.10+, asyncio.get_event_loop() is deprecated when no loop is running.
In Python 3.14+, it raises RuntimeError instead of creating a new loop.
This function provides a compatible way to get or create an event loop.
"""
try:
return asyncio.get_running_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
return loop


def _ensure_executor(executor: ExecutorTypes | None) -> concurrent.Executor:
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

nox.options.default_venv_backend = "uv"

python = ["3.11", "3.12", "3.13"]
python = ["3.11", "3.12", "3.13", "3.14"]
num_cpus = os.cpu_count() or 1
xdist = ("-n", "auto") if num_cpus > 2 else ()

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = [
"scipy",
Expand Down
Loading