mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### Motivation and Context Delete all *_async where *_sync doesn't exist to make the library more Pythonic. Fixes #4629 ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 --------- Co-authored-by: Evan Mattson <[email protected]>
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
import logging
|
|
from typing import Any, Awaitable, Callable, Optional, TypeVar
|
|
|
|
from semantic_kernel.kernel_pydantic import KernelBaseModel
|
|
from semantic_kernel.reliability.retry_mechanism_base import RetryMechanismBase
|
|
|
|
T = TypeVar("T")
|
|
|
|
logger: logging.Logger = logging.getLogger(__name__)
|
|
|
|
|
|
class PassThroughWithoutRetry(RetryMechanismBase, KernelBaseModel):
|
|
"""A retry mechanism that does not retry."""
|
|
|
|
async def execute_with_retry(self, action: Callable[[], Awaitable[T]], log: Optional[Any] = None) -> Awaitable[T]:
|
|
"""Executes the given action with retry logic.
|
|
|
|
Arguments:
|
|
action {Callable[[], Awaitable[T]]} -- The action to retry on exception.
|
|
|
|
Returns:
|
|
Awaitable[T] -- An awaitable that will return the result of the action.
|
|
"""
|
|
if log:
|
|
logger.warning("The `log` parameter is deprecated. Please use the `logging` module instead.")
|
|
try:
|
|
await action()
|
|
except Exception as e:
|
|
logger.warning(e, "Error executing action, not retrying")
|
|
raise
|