mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 17:02:43 +08:00
[Serve] Wait for actor name to be cleaned up (#12215)
This commit is contained in:
+18
-1
@@ -1,4 +1,5 @@
|
||||
import atexit
|
||||
import time
|
||||
from functools import wraps
|
||||
import os
|
||||
from uuid import UUID
|
||||
@@ -81,9 +82,25 @@ class Client:
|
||||
Shuts down all processes and deletes all state associated with the
|
||||
instance.
|
||||
"""
|
||||
if not self._shutdown:
|
||||
if (not self._shutdown) and ray.is_initialized():
|
||||
ray.get(self._controller.shutdown.remote())
|
||||
ray.kill(self._controller, no_restart=True)
|
||||
|
||||
# Wait for the named actor entry gets removed as well.
|
||||
started = time.time()
|
||||
while True:
|
||||
try:
|
||||
ray.get_actor(self._controller_name)
|
||||
if time.time() - started > 5:
|
||||
logger.warning(
|
||||
"Waited 5s for Serve to shutdown gracefully but "
|
||||
"the controller is still not cleaned up. "
|
||||
"You can ignore this warning if you are shutting "
|
||||
"down the Ray cluster.")
|
||||
break
|
||||
except ValueError: # actor name is removed
|
||||
break
|
||||
|
||||
self._shutdown = True
|
||||
|
||||
@_ensure_connected
|
||||
|
||||
Reference in New Issue
Block a user