Skip to content

Commit 41608f8

Browse files
authored
refactor: remove deprecated asyncio.iscoroutinefunction (#599)
Deprecated in 3.14 `asyncio.iscoroutinefunction` is getting promoted to an error in the `dask-cuda` test suite and causing `LocalCUDACluster` to fail to start. `inspect.iscoroutinefunction` has been around since 3.5 and is the recommended switch. xref rapidsai/dask-cuda#1629 Authors: - Gil Forsyth (https://github.com/gforsyth) Approvers: - Tom Augspurger (https://github.com/TomAugspurger) URL: #599
1 parent 8926b3c commit 41608f8

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

python/ucxx/ucxx/_lib_async/listener.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION & AFFILIATES.
1+
# SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES.
22
# SPDX-License-Identifier: BSD-3-Clause
33

44
import asyncio
5+
import inspect
56
import logging
67
import os
78
import threading
@@ -189,7 +190,7 @@ async def _listener_handler_coroutine(
189190
del ctx
190191

191192
# Finally, we call `func`
192-
if asyncio.iscoroutinefunction(func):
193+
if inspect.iscoroutinefunction(func):
193194
try:
194195
await func(ep)
195196
except Exception as e:

python/ucxx/ucxx/_lib_async/tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import asyncio
55
import gc
6+
import inspect
67
import os
78

89
import pytest
@@ -123,7 +124,7 @@ def pytest_pyfunc_call(pyfuncitem: pytest.Function):
123124
else:
124125
reruns = 1
125126

126-
if asyncio.iscoroutinefunction(pyfuncitem.obj) and timeout > 0.0:
127+
if inspect.iscoroutinefunction(pyfuncitem.obj) and timeout > 0.0:
127128

128129
async def wrapped_obj(*args, **kwargs):
129130
for i in range(reruns):

python/ucxx/ucxx/benchmarks/send_recv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: BSD-3-Clause
33

44
import argparse
5-
import asyncio
5+
import inspect
66
import multiprocessing as mp
77
import os
88

@@ -68,7 +68,7 @@ def server(queue, args):
6868

6969
server = _get_backend_implementation(args.backend)["server"](args, queue)
7070

71-
if asyncio.iscoroutinefunction(server.run):
71+
if inspect.iscoroutinefunction(server.run):
7272
loop = get_event_loop()
7373
loop.run_until_complete(server.run())
7474
else:
@@ -85,7 +85,7 @@ def client(queue, port, server_address, args):
8585
args, queue, server_address, port
8686
)
8787

88-
if asyncio.iscoroutinefunction(client.run):
88+
if inspect.iscoroutinefunction(client.run):
8989
loop = get_event_loop()
9090
loop.run_until_complete(client.run())
9191
else:

python/ucxx/ucxx/benchmarks/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: BSD-3-Clause
33

44
import asyncio
5+
import inspect
56
import json
67
import logging
78
import multiprocessing as mp
@@ -256,7 +257,7 @@ async def server_handler(ep):
256257

257258
logger.debug(f"Running worker {rank=}")
258259

259-
if asyncio.iscoroutinefunction(func):
260+
if inspect.iscoroutinefunction(func):
260261
results = await func(rank, eps, args)
261262
else:
262263
results = func(rank, eps, args)

0 commit comments

Comments
 (0)