Skip to content

Commit a0f47f8

Browse files
authored
Fixes hangs when Python future notifier is enabled (#590)
1 parent 791afa6 commit a0f47f8

4 files changed

Lines changed: 15 additions & 38 deletions

File tree

ci/run_python.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ source "$(dirname "$0")/test_common.sh"
1010
# Support invoking run_pytests.sh outside the script directory
1111
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../
1212

13-
# Check if Python version >= 3.13.12 (has asyncio bug)
14-
# Returns 0 if version >= 3.13.12, 1 otherwise
15-
is_python_313_12_or_higher() {
16-
python -c "import sys; exit(0 if sys.version_info >= (3, 13, 12) else 1)"
17-
return $?
18-
}
19-
2013
run_py_tests() {
2114
if [ "${DISABLE_CYTHON:-0}" -eq 0 ]; then
2215
ARGS=("--run-cython")
@@ -85,12 +78,7 @@ run_py_tests
8578
log_message "Python Async Tests"
8679
# run_py_tests_async PROGRESS_MODE ENABLE_DELAYED_SUBMISSION ENABLE_PYTHON_FUTURE SKIP
8780
run_py_tests_async thread 0 0 0
88-
# Skip Python futures tests on Python 3.13.12+ due to asyncio bug: https://github.com/rapidsai/ucxx/issues/586
89-
if is_python_313_12_or_higher; then
90-
run_py_tests_async thread 1 1 1
91-
else
92-
run_py_tests_async thread 1 1 0
93-
fi
81+
run_py_tests_async thread 1 1 0
9482
run_py_tests_async blocking 0 0 0
9583

9684
log_message "Python Benchmarks"

ci/run_python_distributed.sh

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ source "$(dirname "$0")/test_common.sh"
1010
# Support invoking run_pytests.sh outside the script directory
1111
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../
1212

13-
# Check if Python version >= 3.13.12 (has asyncio bug)
14-
# Returns 0 if version >= 3.13.12, 1 otherwise
15-
is_python_313_12_or_higher() {
16-
python -c "import sys; exit(0 if sys.version_info >= (3, 13, 12) else 1)"
17-
return $?
18-
}
19-
2013
install_distributed_dev_mode() {
2114
# Running Distributed tests which access its internals requires installing it in
2215
# developer mode. This isn't a great solution but it's what we can currently do
@@ -84,28 +77,20 @@ run_distributed_ucxx_tests_internal() {
8477
fi
8578
}
8679

87-
# Determine if we should skip Python futures tests (Python 3.13.12+ has asyncio bug)
88-
# See: https://github.com/rapidsai/ucxx/issues/586
89-
if is_python_313_12_or_higher; then
90-
SKIP_PYTHON_FUTURES=1
91-
else
92-
SKIP_PYTHON_FUTURES=0
93-
fi
94-
9580
# run_distributed_ucxx_tests PROGRESS_MODE ENABLE_DELAYED_SUBMISSION ENABLE_PYTHON_FUTURE SKIP
9681
run_distributed_ucxx_tests blocking 0 0 0
9782
run_distributed_ucxx_tests polling 0 0 0
9883
run_distributed_ucxx_tests thread 0 0 0
99-
run_distributed_ucxx_tests thread 0 1 ${SKIP_PYTHON_FUTURES}
84+
run_distributed_ucxx_tests thread 0 1 0
10085
run_distributed_ucxx_tests thread 1 0 0
101-
run_distributed_ucxx_tests thread 1 1 ${SKIP_PYTHON_FUTURES}
86+
run_distributed_ucxx_tests thread 1 1 0
10287

10388
install_distributed_dev_mode
10489

10590
# run_distributed_ucxx_tests_internal PROGRESS_MODE ENABLE_DELAYED_SUBMISSION ENABLE_PYTHON_FUTURE SKIP
10691
run_distributed_ucxx_tests_internal blocking 0 0 0
10792
run_distributed_ucxx_tests_internal polling 0 0 0
10893
run_distributed_ucxx_tests_internal thread 0 0 0
109-
run_distributed_ucxx_tests_internal thread 0 1 ${SKIP_PYTHON_FUTURES}
94+
run_distributed_ucxx_tests_internal thread 0 1 0
11095
run_distributed_ucxx_tests_internal thread 1 0 0
111-
run_distributed_ucxx_tests_internal thread 1 1 ${SKIP_PYTHON_FUTURES}
96+
run_distributed_ucxx_tests_internal thread 1 1 0

python/ucxx/ucxx/_lib_async/notifier_thread.py

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

44

@@ -58,8 +58,10 @@ def _notifierThread(event_loop, worker, q):
5858
try:
5959
task.result(0.01)
6060
except TimeoutError:
61-
task.cancel()
62-
logger.debug("Notifier Thread Result Timeout")
61+
# Do NOT cancel the task here. run_request_notifier() sets asyncio
62+
# Futures for completed UCX requests; cancelling leaves them unset and
63+
# causes send/recv to hang.
64+
logger.debug("Notifier Thread Result Timeout (task left scheduled)")
6365
except Exception as e:
6466
logger.debug(f"Notifier Thread Result Exception: {e}")
6567

python/ucxx/ucxx/_lib_async/utils_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
@@ -185,8 +185,10 @@ async def am_recv(ep):
185185

186186

187187
async def wait_listener_client_handlers(listener):
188-
pass
189188
while listener.active_clients > 0:
190-
await asyncio.sleep(0)
189+
# Minimal delay to yield to the event loop so call_soon_threadsafe callbacks
190+
# run. Using a very short positive sleep ensures pending callbacks are
191+
# processed and significantly reduces "coroutine never awaited" warnings.
192+
await asyncio.sleep(1e-9)
191193
if not ucxx.core._get_ctx().progress_mode.startswith("thread"):
192194
ucxx.progress()

0 commit comments

Comments
 (0)