INNER CODE UNIT · Python

_get_executor

python-cachier/cachier · src/cachier/core.py:105

def _get_executor(reset=False):
    if reset or not hasattr(_get_executor, "executor"):
        _get_executor.executor = ThreadPoolExecutor(_max_workers())
    return _get_executor.executor


def _function_thread(core: _BaseCore, key, func, args, kwds):
    try:
        func_res = func(*args, **kwds)
        core.set_entry(key, func_res)
    except BaseException as exc:
        print(f"Function call failed with the following exception:\n{exc}")


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)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…