Skip to content

Commit

Permalink
Fix livereload shutdown sequence - crash on Windows
Browse files Browse the repository at this point in the history
Fixes #3305
Regressed in commit d4d483c
  • Loading branch information
oprypin committed Jul 26, 2023
1 parent bfb52a3 commit 0f8ab6b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions mkdocs/livereload/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,18 @@ def unwatch(self, path: str) -> None:
self.observer.unschedule(self._watch_refs.pop(path))

def serve(self):
try:
self.server_bind()
self.server_activate()
self.server_bind()
self.server_activate()

self.observer.start()
self.observer.start()

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

log.info(f"Serving on {self.url}")
self.serve_thread.start()
log.info(f"Serving on {self.url}")
self.serve_thread.start()

self._build_loop()
finally:
self.server_close()
self._build_loop()

def _build_loop(self):
while True:
Expand Down Expand Up @@ -213,6 +210,7 @@ def shutdown(self, wait=False) -> None:

if self.serve_thread.is_alive():
super().shutdown()
self.server_close()
if wait:
self.serve_thread.join()
self.observer.join()
Expand Down

0 comments on commit 0f8ab6b

Please sign in to comment.