diff --git a/cista/app.py b/cista/app.py index 6c879b5..49e33cf 100644 --- a/cista/app.py +++ b/cista/app.py @@ -3,6 +3,7 @@ import datetime import mimetypes import threading from concurrent.futures import ThreadPoolExecutor +from multiprocessing import cpu_count from pathlib import Path, PurePath, PurePosixPath from stat import S_IFDIR, S_IFREG from urllib.parse import unquote @@ -33,8 +34,9 @@ app.exception(Exception)(handle_sanic_exception) @app.before_server_start async def main_start(app, loop): config.load_config() + N = max(2, min(8, cpu_count())) app.ctx.threadexec = ThreadPoolExecutor( - max_workers=3, thread_name_prefix="cista-ioworker" + max_workers=N, thread_name_prefix="cista-ioworker" ) await watching.start(app, loop)