Skip to content

Commit

Permalink
Merge pull request #276 from kkostov/fix-event-loop-error
Browse files Browse the repository at this point in the history
fix(#170): wait for the IOLoop to stop before attempting to close it
  • Loading branch information
lepture authored Oct 4, 2024
2 parents 62d016a + 5453629 commit 96fb2e1
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 96fb2e1

Please sign in to comment.