Repository: jina-ai/jina
File: jina/clients/base/grpc.py (Python)

Code before:
        compression: Optional[str] = None,
        max_attempts: int = 1,
        initial_backoff: float = 0.5,
        max_backoff: float = 0.1,
        backoff_multiplier: float = 1.5,
        results_in_order: bool = False,
        stream: bool = False,
        **kwargs,
    ):
        try:
            self.compression = (
                getattr(grpc.Compression, compression)
                if compression
                else grpc.Compression.NoCompression
            )

            self.inputs = inputs
            req_iter = self._get_requests(**kwargs)
            continue_on_error = self.continue_on_error
            # while loop with retries, check in which state the `iterator` remains after failure
            options = GrpcConnectionPool.get_default_grpc_options()
            if max_attempts > 1:
                service_config_json = json.dumps(
                    {
                        "methodConfig": [
                            {
                                # To apply retry to all methods, put [{}] in the "name" field
                                "name": [{}],
                                "retryPolicy": {
                                    "maxAttempts": max_attempts,
                                    "initialBackoff": f"{initial_backoff}s",
                                    "maxBackoff": f"{max_backoff}s",
                                    "backoffMultiplier": backoff_multiplier,
                                    "retryableStatusCodes": [
                                        "UNAVAILABLE",
                                        "DEADLINE_EXCEEDED",
                                        "INTERNAL",
                                    ],
                                },
                            }
                        ]
                    }
                )
                # NOTE: the retry feature will be enabled by default >=v1.40.0
                options.append(("grpc.enable_retries", 1))
                options.append(("grpc.service_config", service_config_json))

            metadata = kwargs.pop('metadata', None)
            if results_in_order:
                metadata = metadata or ()
                metadata = metadata + (('__results_in_order__', 'true'),)

Review comment (suggestion):
Small issue that we can fix later. This default value is different than the default value in the `.post` method. I forgot to update the default here last time.

Code after:
            request_handler=_request_handler,
            result_handler=_result_handler,
            iterate_sync_in_thread=False,
            logger=self.logger,
            **vars(self.args),
        )
        async for response in streamer.stream(
                request_iterator=req_iter, results_in_order=results_in_order
        ):
            if self.show_progress:
                p_bar.update()
            yield response

    async def _get_results(
            self,
            inputs: 'InputType',
            on_done: 'CallbackFnType',
            on_error: Optional['CallbackFnType'] = None,
            on_always: Optional['CallbackFnType'] = None,
            compression: Optional[str] = None,
            max_attempts: int = 1,
            initial_backoff: float = 0.5,
            max_backoff: float = 0.1,
            backoff_multiplier: float = 1.5,
            results_in_order: bool = False,
            stream: bool = False,
            **kwargs,
    ):
        try:
            self.compression = (
                getattr(grpc.Compression, compression)
                if compression
                else grpc.Compression.NoCompression
            )

            self.inputs = inputs
            req_iter = self._get_requests(**kwargs)
            continue_on_error = self.continue_on_error
            # while loop with retries, check in which state the `iterator` remains after failure
            options = GrpcConnectionPool.get_default_grpc_options()
            if max_attempts > 1:
                service_config_json = json.dumps(
                    {
                        "methodConfig": [
                            {
                                # To apply retry to all methods, put [{}] in the "name" field
                                "name": [{}],
                                "retryPolicy": {
                                    "maxAttempts": max_attempts,
                                    "initialBackoff": f"{initial_backoff}s",
                                    "maxBackoff": f"{max_backoff}s",