Skip to content

Commit 8d4c0e8

Browse files
authored
[Data] Close threads from async UDF after actor died (#59261)
## Description When using async map with actors in Ray Data, the asyncio thread can keep the actor process alive and block shutdown even after the actor is marked as dead. This occurs because the asyncio thread does not exit when the main thread finishes. To fix this, we create the thread with `daemon=True`, ensuring it terminates when the main thread exits. ## Related issues Closes #59033 Signed-off-by: You-Cheng Lin <mses010108@gmail.com>
1 parent 30f8772 commit 8d4c0e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python/ray/data/_internal/planner/plan_udf_map_op.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def run_loop():
9999
asyncio.set_event_loop(loop)
100100
loop.run_forever()
101101

102-
thread = Thread(target=run_loop)
102+
thread = Thread(target=run_loop, daemon=True)
103103
thread.start()
104104
self.udf_map_asyncio_loop = loop
105105
self.udf_map_asyncio_thread = thread

0 commit comments

Comments
 (0)