Skip to content

Commit 0d560f9

Browse files
Replace asyncio.iscoroutinefunction with inspect.iscoroutinefunction
Fixes #3879
1 parent 34db73e commit 0d560f9

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
1212
## Unreleased
1313

14+
### Fixed
15+
16+
- Replace Python 3.14-deprecated `asyncio.iscoroutinefunction` with `inspect.iscoroutinefunction`. ([#3880](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3880))
17+
1418
## Version 1.38.0/0.59b0 (2025-10-16)
1519

1620
### Fixed

instrumentation/opentelemetry-instrumentation-aiokafka/src/opentelemetry/instrumentation/aiokafka/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async def produce():
9595

9696
from __future__ import annotations
9797

98-
from asyncio import iscoroutinefunction
98+
from inspect import iscoroutinefunction
9999
from typing import TYPE_CHECKING, Collection
100100

101101
import aiokafka

instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import asyncio
1+
import inspect
22
import typing
33
from collections.abc import Coroutine
44

@@ -197,7 +197,7 @@ async def __aenter__(self):
197197

198198
async def __aexit__(self, exc_type, exc, t_b):
199199
try:
200-
if asyncio.iscoroutinefunction(self._obj.close):
200+
if inspect.iscoroutinefunction(self._obj.close):
201201
await self._obj.close()
202202
else:
203203
self._obj.close()

instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ async def async_response_hook(span, request, response):
207207

208208
import logging
209209
import typing
210-
from asyncio import iscoroutinefunction
210+
from inspect import iscoroutinefunction
211211
from functools import partial
212212
from timeit import default_timer
213213
from types import TracebackType

instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import abc
1818
import asyncio
19+
import inspect
1920
import typing
2021
from unittest import mock
2122

@@ -1046,7 +1047,7 @@ def test_custom_tracer_provider(self):
10461047
def test_response_hook(self):
10471048
response_hook_key = (
10481049
"async_response_hook"
1049-
if asyncio.iscoroutinefunction(self.response_hook)
1050+
if inspect.iscoroutinefunction(self.response_hook)
10501051
else "response_hook"
10511052
)
10521053
response_hook_kwargs = {response_hook_key: self.response_hook}
@@ -1093,7 +1094,7 @@ def test_response_hook_sync_async_kwargs(self):
10931094
def test_request_hook(self):
10941095
request_hook_key = (
10951096
"async_request_hook"
1096-
if asyncio.iscoroutinefunction(self.request_hook)
1097+
if inspect.iscoroutinefunction(self.request_hook)
10971098
else "request_hook"
10981099
)
10991100
request_hook_kwargs = {request_hook_key: self.request_hook}

0 commit comments

Comments
 (0)