Files
semantic-kernel/python/semantic_kernel/reliability/pass_through_without_retry.py
T
Abby Harrison 7a884d4e57 Python: make abstraction usage consistent (#1052)
### Motivation and Context
Use of abstraction was not consistent in the python SK. This PR makes
the import and use of ABC consistent and removes unused file kernel.py.

### Description
- MemoryStoreBase derives from ABC - this properly sets its metaclass.
MemoryStoreBase itself should never be instantiated, only derived.
- RetryMechanism derives ABC, so should be named 'Base' like all other
derivatives of ABC in this repo.
- removed kernel_base.py, was made obsolete by
https://github.com/microsoft/semantic-kernel/pull/1015
2023-05-19 11:42:26 -07:00

31 lines
932 B
Python

# Copyright (c) Microsoft. All rights reserved.
import logging
from typing import Awaitable, Callable, TypeVar
from semantic_kernel.reliability.retry_mechanism_base import RetryMechanismBase
T = TypeVar("T")
class PassThroughWithoutRetry(RetryMechanismBase):
"""A retry mechanism that does not retry."""
async def execute_with_retry_async(
self, action: Callable[[], Awaitable[T]], log: logging.Logger
) -> Awaitable[T]:
"""Executes the given action with retry logic.
Arguments:
action {Callable[[], Awaitable[T]]} -- The action to retry on exception.
log {logging.Logger} -- The logger to use.
Returns:
Awaitable[T] -- An awaitable that will return the result of the action.
"""
try:
await action()
except Exception as e:
log.warning(e, "Error executing action, not retrying")
raise