Skip to content

[Data] Close threads from async UDF after actor died#59261

Merged
alexeykudinkin merged 2 commits into
ray-project:masterfrom
owenowenisme:data/fix-dead-actor-did-not-stop-async-thread
Dec 9, 2025
Merged

[Data] Close threads from async UDF after actor died#59261
alexeykudinkin merged 2 commits into
ray-project:masterfrom
owenowenisme:data/fix-dead-actor-did-not-stop-async-thread

Conversation

@owenowenisme

Copy link
Copy Markdown
Member

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>
@owenowenisme owenowenisme requested a review from a team as a code owner December 8, 2025 13:46
@owenowenisme owenowenisme added data Ray Data-related issues go add ONLY when ready to merge, run all tests labels Dec 8, 2025

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an issue where asyncio threads in async UDFs could prevent actor processes from shutting down correctly. The proposed fix of setting daemon=True when creating the thread is the correct and standard approach to ensure that these background threads do not block the main process from exiting. The change is concise, well-targeted, and effectively resolves the described problem.

@alexeykudinkin alexeykudinkin merged commit 8d4c0e8 into ray-project:master Dec 9, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests

2 participants