mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### 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
31 lines
932 B
Python
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
|