diff --git a/NEWS.rst b/NEWS.rst index 311ce77..657a703 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -7,6 +7,7 @@ unreleased * Drop ``python-livereload``. * Add ``starlette`` and ``uvicorn`` as dependencies. * Implement hot reloading via websockets. +* Run Sphinx rebuilds in an asynchronous executor. 2024.02.04 - 2024-02-04 ----------------------- diff --git a/sphinx_autobuild/server.py b/sphinx_autobuild/server.py index 1b7673a..def7737 100644 --- a/sphinx_autobuild/server.py +++ b/sphinx_autobuild/server.py @@ -2,6 +2,7 @@ import asyncio import os +from concurrent.futures import ProcessPoolExecutor from contextlib import AbstractAsyncContextManager, asynccontextmanager import watchfiles @@ -50,7 +51,9 @@ async def watch(self) -> None: *self.paths, watch_filter=lambda _, path: not self.ignore(path), ): - self.change_callback() + with ProcessPoolExecutor() as pool: + fut = pool.submit(self.change_callback) + await asyncio.wrap_future(fut) self.flag.set() async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: