Skip to content

Commit

Permalink
fix(#170): wait for the IOLoop to be stopped before attempting to clo…
Browse files Browse the repository at this point in the history
…se it.
  • Loading branch information
kkostov committed Jun 29, 2024
1 parent 62d016a commit 5453629
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion livereload/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,12 @@ def opener():
try:
self.watcher._changes.append(('__livereload__', restart_delay))
LiveReloadHandler.start_tasks()
add_reload_hook(lambda: IOLoop.instance().close(all_fds=True))
# When autoreload is triggered, initiate a shutdown of the IOLoop
add_reload_hook(lambda: IOLoop.instance().stop())
# The call to start() does not return until the IOLoop is stopped.
IOLoop.instance().start()
# Once the IOLoop is stopped, the IOLoop can be closed to free resources
IOLoop.current().close(all_fds=True)
except KeyboardInterrupt:
logger.info('Shutting down...')

Expand Down

0 comments on commit 5453629

Please sign in to comment.