INNER CODE UNIT · Python
_function_thread_async
python-cachier/cachier · src/cachier/core.py:119
async def _function_thread_async(core: _BaseCore, key, func, args, kwds):
try:
func_res = await func(*args, **kwds)
await core.aset_entry(key, func_res)
except BaseException as exc:
print(f"Function call failed with the following exception:\n{exc}")
def _calc_entry(core: _BaseCore, key, func, args, kwds, printer=lambda *_: None) -> Optional[Any]:
core.mark_entry_being_calculated(key)
try:
func_res = func(*args, **kwds)
stored = core.set_entry(key, func_res)
if not stored:
printer("Result exceeds entry_size_limit; not cached")
return func_res
finally:
core.mark_entry_not_calculated(key)