Skip to content

Conversation

@owenowenisme
Copy link
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
Copy link
Contributor

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ray Data] Async UDF actor leaks in map_batches

2 participants