mirror of
https://github.com/wassname/ray.git
synced 2026-07-09 01:03:34 +08:00
Fix worker exit cleanup (#6450)
* working but ugly * comments * proper but hanging in grpc server destructor * grpc server shutdown deadline * fix disconnect * lint * shutdown_only in test * replace shutdown
This commit is contained in:
@@ -431,6 +431,7 @@ class Worker(object):
|
||||
|
||||
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||
self.core_worker.run_task_loop()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def get_gpu_ids():
|
||||
@@ -834,6 +835,12 @@ def shutdown(exiting_interpreter=False):
|
||||
|
||||
disconnect(exiting_interpreter)
|
||||
|
||||
# We need to destruct the core worker here because after this function,
|
||||
# we will tear down any processes spawned by ray.init() and the background
|
||||
# IO thread in the core worker doesn't currently handle that gracefully.
|
||||
if hasattr(global_worker, "core_worker"):
|
||||
del global_worker.core_worker
|
||||
|
||||
# Disconnect global state from GCS.
|
||||
ray.state.state.disconnect()
|
||||
|
||||
@@ -843,7 +850,7 @@ def shutdown(exiting_interpreter=False):
|
||||
_global_node.kill_all_processes(check_alive=False, allow_graceful=True)
|
||||
_global_node = None
|
||||
|
||||
# TODO(rkn): Instead of manually reseting some of the worker fields, we
|
||||
# TODO(rkn): Instead of manually resetting some of the worker fields, we
|
||||
# should simply set "global_worker" to equal "None" or something like that.
|
||||
global_worker.set_mode(None)
|
||||
global_worker._post_get_hooks = []
|
||||
@@ -1332,12 +1339,6 @@ def disconnect(exiting_interpreter=False):
|
||||
worker.cached_functions_to_run = []
|
||||
worker.serialization_context_map.clear()
|
||||
|
||||
# We need to destruct the core worker here because after this function,
|
||||
# we will tear down any processes spawned by ray.init() and the background
|
||||
# threads in the core worker don't currently handle that gracefully.
|
||||
if hasattr(worker, "core_worker"):
|
||||
del worker.core_worker
|
||||
|
||||
|
||||
@contextmanager
|
||||
def _changeproctitle(title, next_title):
|
||||
|
||||
Reference in New Issue
Block a user