def disconnect():
    """Disconnect this worker from the raylet and object store."""
    # Reset the list of cached remote functions and actors so that if more
    # remote functions or actors are defined and then connect is called again,
    # the remote functions will be exported. This is mostly relevant for the
    # tests.
    worker = global_worker
    if worker.connected:
        # Shutdown all of the threads that we've started. TODO(rkn): This
        # should be handled cleanly in the worker object's destructor and not
        # in this disconnect method.
        worker.threads_stopped.set()
        if hasattr(worker, "import_thread"):
            worker.import_thread.join_import_thread()
        if hasattr(worker, "profiler") and hasattr(worker.profiler, "t"):
            worker.profiler.join_flush_thread()
        if hasattr(worker, "listener_thread"):
            worker.listener_thread.join()
        if hasattr(worker, "printer_thread"):
            worker.printer_thread.join()
        if hasattr(worker, "logger_thread"):
            worker.logger_thread.join()
        worker.threads_stopped.clear()
        worker._session_index += 1

    worker.node = None  # Disconnect the worker from the node.
    worker.cached_functions_to_run = []
    worker.function_actor_manager.reset_cache()
    worker.serialization_context_map.clear()

    if hasattr(worker, "raylet_client"):
        del worker.raylet_client
    if hasattr(worker, "plasma_client"):
        worker.plasma_client.disconnect()
def disconnect ( ) : worker = global_worker if worker . connected : worker . threads_stopped . set ( ) if hasattr ( worker , "import_thread" ) : worker . import_thread . join_import_thread ( ) if hasattr ( worker , "profiler" ) and hasattr ( worker . profiler , "t" ) : worker . profiler . join_flush_thread ( ) if hasattr ( worker , "listener_thread" ) : worker . listener_thread . join ( ) if hasattr ( worker , "printer_thread" ) : worker . printer_thread . join ( ) if hasattr ( worker , "logger_thread" ) : worker . logger_thread . join ( ) worker . threads_stopped . clear ( ) worker . _session_index += 1 worker . node = None worker . cached_functions_to_run = [ ] worker . function_actor_manager . reset_cache ( ) worker . serialization_context_map . clear ( ) if hasattr ( worker , "raylet_client" ) : del worker . raylet_client if hasattr ( worker , "plasma_client" ) : worker . plasma_client . disconnect ( )
Disconnect this worker from the raylet and object store.