Skip to content

Commit 98d0431

Browse files
committed
Uses iscoroutinefunction from inspect module
1 parent c6ae8e5 commit 98d0431

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

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
@@ -225,8 +225,8 @@ async def async_response_hook(span, request, response):
225225

226226
import logging
227227
import typing
228-
from asyncio import iscoroutinefunction
229228
from functools import partial
229+
from inspect import iscoroutinefunction
230230
from timeit import default_timer
231231
from types import TracebackType
232232

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

@@ -1086,7 +1087,7 @@ def test_custom_tracer_provider(self):
10861087
def test_response_hook(self):
10871088
response_hook_key = (
10881089
"async_response_hook"
1089-
if asyncio.iscoroutinefunction(self.response_hook)
1090+
if inspect.iscoroutinefunction(self.response_hook)
10901091
else "response_hook"
10911092
)
10921093
response_hook_kwargs = {response_hook_key: self.response_hook}
@@ -1133,7 +1134,7 @@ def test_response_hook_sync_async_kwargs(self):
11331134
def test_request_hook(self):
11341135
request_hook_key = (
11351136
"async_request_hook"
1136-
if asyncio.iscoroutinefunction(self.request_hook)
1137+
if inspect.iscoroutinefunction(self.request_hook)
11371138
else "request_hook"
11381139
)
11391140
request_hook_kwargs = {request_hook_key: self.request_hook}

0 commit comments

Comments
 (0)