-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): all
- Ray installed from (source or binary): source
- Ray version: latest master
- Python version: all
- Exact command to reproduce: n/a
Describe the problem
Currently, when the original actor handle is garbage collected by Python interpreter, a __ray_terminate__ message will be sent to also terminate the actor, see
Line 662 in 06f6431
| def __del__(self): |
This mechanism is problematic, because
- If there're forked handles, the actor shouldn't be terminated.
__del__is unreliable and not recommended to use, see https://stackoverflow.com/questions/1481488/what-is-the-del-method-how-to-call-it.
The first point is a critical problem and is hard to handle automatically. Even if we count the number of forked handles, and only terminate the actor when all handles are GC'ed. It's still problematic if users serialize a handle and deserialize it after a long time. Ray doesn't know when an actor is not needed any more. Only the user knows.
Thus, I'm in favor of letting the users manually GC an actor with actor.__ray_terminate__.remote(), when they don't need the actor any more. To prevent the actor from wasting resource forever, there's already the mechanism that we'll clean up all workers when a driver exits.