Skip to content

[BUG CLIENT]: test_otel_tracing tests fail on Python 3.14 — asyncio.get_event_loop() removed #490

@mcepl

Description

@mcepl

Python -VV

Two tests in src/mistralai/extra/tests/test_otel_tracing.py fail on Python 3.14:
- TestOtelTracing::test_create_function_result_span_attributes
- TestOtelTracing::test_create_function_result_error_span
Error:
RuntimeError: There is no current event loop in thread 'MainThread'.
at /usr/lib64/python3.14/asyncio/events.py:715
Cause:
Both tests call asyncio.get_event_loop().run_until_complete(...). The implicit creation of a default event loop in the main thread was deprecated in Python 3.10 (bpo-39529 (https://bugs.python.org/issue39529)) and removed in Python 3.14 (python/cpython#99949 (https://github.com/python/cpython/issues/99949)). Calling asyncio.get_event_loop() now unconditionally raises RuntimeError when no loop has been explicitly set.
Affected file: src/mistralai/extra/tests/test_otel_tracing.py, lines ~1463 and ~1505.

Environment:
- mistralai version: 2.3.2
- Python: 3.14 (fails); 3.11 and 3.13 pass

Pip Freeze

annotated-types==0.7.0
anyio==4.12.1
attrs==26.1.0
bcrypt==4.3.0
certifi==2026.2.25
cffi==2.0.0
charset-normalizer==3.4.7
click==8.3.2
colorama==0.4.6
cryptography==46.0.7
Deprecated==1.3.1
eval_type_backport==0.3.1
fluidity-sm==0.2.0
googleapis-common-protos==1.74.0
griffe==2.0.2
griffe-inherited-docstrings==1.1.3
griffecli==2.0.2
griffelib==2.0.2
h11==0.16.0
hatchling==1.27.0
httpcore==1.0.9
httpx==0.28.1
httpx-sse==0.4.0
idna==3.11
importlib_metadata==9.0.0
iniconfig==2.3.0
invoke==2.2.1
jsonpath-python==1.0.6
jsonschema==4.26.0
jsonschema-specifications==2025.9.1
lexicon==3.0.0
maturin==1.12.6
mcp==1.27.0
opentelemetry-api==1.40.0
opentelemetry-exporter-otlp-proto-common==1.40.0
opentelemetry-exporter-otlp-proto-http==1.40.0
opentelemetry-proto==1.40.0
opentelemetry-sdk==1.40.0
opentelemetry-semantic-conventions==0.61b0
packaging==26.0
pathspec==1.0.4
pluggy==1.6.0
protobuf==7.34.1
pycparser==3.0
pydantic==2.12.5
pydantic-settings==2.13.1
pydantic_core==2.41.5
Pygments==2.20.0
pytest==9.0.2
python-dateutil==2.9.0.post0
python-dotenv==1.2.2
python-multipart==0.0.22
PyYAML==6.0.3
referencing==0.37.0
requests==2.33.1
rpds-py==0.27.1
rpm==4.20.1
setuptools==80.9.0
sniffio==1.3.1
sse-starlette==2.3.6
starlette==1.0.0
trove-classifiers==2026.1.14.14
typing-inspection==0.4.2
typing_extensions==4.15.0
urllib3==2.6.3
uvicorn==0.40.0
wrapt==2.1.2
zipp==3.23.0

Reproduction Steps

  1. Run the test suite with Python 3.14

See the complete build log with all details of packages and steps taken to reproduce

Expected Behavior

test suite should pass even with Python 3.14

Additional Context

No response

Suggested Solutions

Fix:
Replace asyncio.get_event_loop().run_until_complete(coro) with asyncio.run(coro) in those two test methods:

Before (broken on Python 3.14):

result = asyncio.get_event_loop().run_until_complete(
create_function_result(function_call, run_tool)
)

After:

result = asyncio.run(
create_function_result(function_call, run_tool)
)
asyncio.run() is available since Python 3.7 and is the recommended replacement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions