Skip to content

Commit 0f8ab6b

Browse files
committed
Fix livereload shutdown sequence - crash on Windows
Fixes #3305 Regressed in commit d4d483c
1 parent bfb52a3 commit 0f8ab6b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

mkdocs/livereload/__init__.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,18 @@ def unwatch(self, path: str) -> None:
152152
self.observer.unschedule(self._watch_refs.pop(path))
153153

154154
def serve(self):
155-
try:
156-
self.server_bind()
157-
self.server_activate()
155+
self.server_bind()
156+
self.server_activate()
158157

159-
self.observer.start()
158+
self.observer.start()
160159

161-
paths_str = ", ".join(f"'{_try_relativize_path(path)}'" for path in self._watched_paths)
162-
log.info(f"Watching paths for changes: {paths_str}")
160+
paths_str = ", ".join(f"'{_try_relativize_path(path)}'" for path in self._watched_paths)
161+
log.info(f"Watching paths for changes: {paths_str}")
163162

164-
log.info(f"Serving on {self.url}")
165-
self.serve_thread.start()
163+
log.info(f"Serving on {self.url}")
164+
self.serve_thread.start()
166165

167-
self._build_loop()
168-
finally:
169-
self.server_close()
166+
self._build_loop()
170167

171168
def _build_loop(self):
172169
while True:
@@ -213,6 +210,7 @@ def shutdown(self, wait=False) -> None:
213210

214211
if self.serve_thread.is_alive():
215212
super().shutdown()
213+
self.server_close()
216214
if wait:
217215
self.serve_thread.join()
218216
self.observer.join()

0 commit comments

Comments
 (0)