Skip to content

Commit e291fe2

Browse files
Make live reload a little more reliable (#576)
1 parent 3969b00 commit e291fe2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

aiohttp_devtools/runserver/watch.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(self, config: Config):
5757
assert self._config.watch_path
5858
super().__init__(self._config.watch_path)
5959

60-
async def _run(self, live_checks: int = 20) -> None:
60+
async def _run(self, live_checks: int = 150) -> None:
6161
assert self._app is not None
6262

6363
self._session = ClientSession()
@@ -76,6 +76,9 @@ def is_static(changes: Iterable[Tuple[object, str]]) -> bool:
7676
await self._stop_dev_server()
7777
self._start_dev_server()
7878
await self._src_reload_when_live(live_checks)
79+
# Pause to allow the browser to reload and reconnect. This avoids
80+
# multiple changes causing the app to restart before WS reconnection.
81+
await asyncio.sleep(1)
7982
elif len(changes) == 1 and is_static(changes):
8083
# a single (static) file has changed, reload a single file.
8184
await src_reload(self._app, changes.pop()[1])
@@ -87,7 +90,7 @@ def is_static(changes: Iterable[Tuple[object, str]]) -> bool:
8790
await self._session.close()
8891
raise AiohttpDevException('error running dev server')
8992

90-
async def _src_reload_when_live(self, checks: int = 20) -> None:
93+
async def _src_reload_when_live(self, checks: int) -> None:
9194
assert self._app is not None and self._session is not None
9295

9396
if self._app[WS]:

0 commit comments

Comments
 (0)