Skip to content

Commit

Permalink
Run change_callback in an asynchronous executor
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Apr 9, 2024
1 parent 49af6e1 commit fda9582
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------------
Expand Down
5 changes: 4 additions & 1 deletion sphinx_autobuild/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio
import os
from concurrent.futures import ProcessPoolExecutor
from contextlib import AbstractAsyncContextManager, asynccontextmanager

import watchfiles
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit fda9582

Please sign in to comment.