Retry failed and cancelled async predictions instead of caching errors
This commit is contained in:
parent
32df6504cc
commit
b46736062a
2 changed files with 30 additions and 3 deletions
|
|
@ -265,7 +265,7 @@ class GreatAI(Generic[T, V]):
|
|||
result = func(*args, **kwargs)
|
||||
return cast(T, t.finalise(output=result))
|
||||
|
||||
@alru_cache(maxsize=get_context().prediction_cache_size)
|
||||
@alru_cache(maxsize=get_context().prediction_cache_size, cache_exceptions=False)
|
||||
async def func_in_tracing_context_async(
|
||||
*args: Any,
|
||||
do_not_persist_traces: bool = False,
|
||||
|
|
|
|||
4
great_ai/external/async_lru.py
vendored
4
great_ai/external/async_lru.py
vendored
|
|
@ -148,9 +148,9 @@ def alru_cache(
|
|||
_cache_hit(wrapped, key)
|
||||
return await asyncio.shield(fut)
|
||||
|
||||
exc = fut._exception
|
||||
exc = None if fut.cancelled() else fut.exception()
|
||||
|
||||
if exc is None or cache_exceptions:
|
||||
if not fut.cancelled() and (exc is None or cache_exceptions):
|
||||
_cache_hit(wrapped, key)
|
||||
return fut.result()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue