MCPcopy
hub / github.com/ray-project/ray / _deserialization_helper

Method _deserialization_helper

python/ray/actor.py:2593–2638  ·  view source on GitHub ↗

This is defined in order to make pickling work. Args: state: The serialized state of the actor handle. outer_object_ref: The ObjectRef that the serialized actor handle was contained in, if any. This is used for counting references to t

(cls, state, weak_ref: bool, outer_object_ref=None)

Source from the content-addressed store, hash-verified

2591
2592 @classmethod
2593 def _deserialization_helper(cls, state, weak_ref: bool, outer_object_ref=None):
2594 """This is defined in order to make pickling work.
2595
2596 Args:
2597 state: The serialized state of the actor handle.
2598 outer_object_ref: The ObjectRef that the serialized actor handle
2599 was contained in, if any. This is used for counting references
2600 to the actor handle.
2601 weak_ref: Whether this was serialized from an actor handle with a
2602 weak ref to the actor.
2603
2604 """
2605 worker = ray._private.worker.global_worker
2606 worker.check_connected()
2607
2608 if hasattr(worker, "core_worker"):
2609 # Non-local mode
2610 return worker.core_worker.deserialize_and_register_actor_handle(
2611 state,
2612 outer_object_ref,
2613 weak_ref,
2614 )
2615 else:
2616 # Local mode
2617 assert worker.current_cluster_and_job == state["current_cluster_and_job"]
2618 return cls(
2619 # TODO(swang): Accessing the worker's current task ID is not
2620 # thread-safe.
2621 state["actor_language"],
2622 state["actor_id"],
2623 state["max_task_retries"],
2624 state["enable_task_events"],
2625 state["method_is_generator"],
2626 state["method_decorators"],
2627 state["method_signatures"],
2628 state["method_num_returns"],
2629 state["method_max_task_retries"],
2630 state["method_retry_exceptions"],
2631 state["method_generator_backpressure_num_objects"],
2632 state["method_enable_task_events"],
2633 state["enable_tensor_transport"],
2634 state["method_name_to_tensor_transport"],
2635 state["actor_method_cpus"],
2636 state["actor_creation_function_descriptor"],
2637 state["current_cluster_and_job"],
2638 )
2639
2640 def __reduce__(self):
2641 """This code path is used by pickling but not by Ray forking."""

Callers 1

Calls 2

clsClass · 0.85
check_connectedMethod · 0.45

Tested by

no test coverage detected