A container for the metadata required to invoke an actor method. This class intentionally does *not* hold a reference to the `ActorHandle`, as that causes a circular reference that delays `ActorHandle` destruction until the Python GC runs. Instead, it can be used as a factory to lazily
| 743 | |
| 744 | |
| 745 | class _ActorMethodMetadata: |
| 746 | """A container for the metadata required to invoke an actor method. |
| 747 | |
| 748 | This class intentionally does *not* hold a reference to the `ActorHandle`, as that causes |
| 749 | a circular reference that delays `ActorHandle` destruction until the Python GC runs. |
| 750 | |
| 751 | Instead, it can be used as a factory to lazily generate `ActorMethod` instances that can |
| 752 | be used to submit actor tasks for this method. |
| 753 | """ |
| 754 | |
| 755 | def __init__( |
| 756 | self, |
| 757 | method_name: str, |
| 758 | num_returns: Optional[Union[int, Literal["streaming"]]], |
| 759 | max_task_retries: int, |
| 760 | retry_exceptions: Union[bool, list, tuple], |
| 761 | is_generator: bool, |
| 762 | generator_backpressure_num_objects: int, |
| 763 | enable_task_events: bool, |
| 764 | decorator: Optional[Any] = None, |
| 765 | signature: Optional[List[inspect.Parameter]] = None, |
| 766 | tensor_transport: Optional[str] = None, |
| 767 | ): |
| 768 | """Initialize an _ActorMethodMetadata. |
| 769 | |
| 770 | Args: |
| 771 | method_name: The name of the actor method. |
| 772 | num_returns: The default number of return values that the method |
| 773 | invocation should return. If None is given, it uses |
| 774 | DEFAULT_ACTOR_METHOD_NUM_RETURN_VALS for a normal actor task |
| 775 | and "streaming" for a generator task (when `is_generator` is True). |
| 776 | max_task_retries: Number of retries on method failure. |
| 777 | retry_exceptions: Boolean or list/tuple of exceptions to retry. |
| 778 | is_generator: True if the method is a generator. |
| 779 | generator_backpressure_num_objects: Generator-only config for backpressure. |
| 780 | enable_task_events: True if task events are enabled for this method. |
| 781 | decorator: Optional decorator for the method invocation. |
| 782 | signature: The signature of the actor method. |
| 783 | tensor_transport: The tensor transport protocol to use for the actor method. |
| 784 | """ |
| 785 | self._method_name = method_name |
| 786 | |
| 787 | # Default case. |
| 788 | if num_returns is None: |
| 789 | if is_generator: |
| 790 | num_returns = "streaming" |
| 791 | else: |
| 792 | num_returns = ray_constants.DEFAULT_ACTOR_METHOD_NUM_RETURN_VALS |
| 793 | self._num_returns = num_returns |
| 794 | self._max_task_retries = max_task_retries |
| 795 | self._retry_exceptions = retry_exceptions |
| 796 | self._is_generator = is_generator |
| 797 | self._generator_backpressure_num_objects = generator_backpressure_num_objects |
| 798 | self._enable_task_events = enable_task_events |
| 799 | self._decorator = decorator |
| 800 | self._signature = signature |
| 801 | self._tensor_transport = tensor_transport |
| 802 |
no outgoing calls
no test coverage detected
searching dependent graphs…