@@ -57,7 +57,7 @@ def __init__(self, config: Config):
57
57
assert self ._config .watch_path
58
58
super ().__init__ (self ._config .watch_path )
59
59
60
- async def _run (self , live_checks : int = 20 ) -> None :
60
+ async def _run (self , live_checks : int = 150 ) -> None :
61
61
assert self ._app is not None
62
62
63
63
self ._session = ClientSession ()
@@ -76,6 +76,9 @@ def is_static(changes: Iterable[Tuple[object, str]]) -> bool:
76
76
await self ._stop_dev_server ()
77
77
self ._start_dev_server ()
78
78
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 )
79
82
elif len (changes ) == 1 and is_static (changes ):
80
83
# a single (static) file has changed, reload a single file.
81
84
await src_reload (self ._app , changes .pop ()[1 ])
@@ -87,7 +90,7 @@ def is_static(changes: Iterable[Tuple[object, str]]) -> bool:
87
90
await self ._session .close ()
88
91
raise AiohttpDevException ('error running dev server' )
89
92
90
- async def _src_reload_when_live (self , checks : int = 20 ) -> None :
93
+ async def _src_reload_when_live (self , checks : int ) -> None :
91
94
assert self ._app is not None and self ._session is not None
92
95
93
96
if self ._app [WS ]:
0 commit comments