Skip to content

Commit 96fb2e1

Browse files
authored
Merge pull request #276 from kkostov/fix-event-loop-error
fix(#170): wait for the IOLoop to stop before attempting to close it
2 parents 62d016a + 5453629 commit 96fb2e1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

livereload/server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,12 @@ def opener():
347347
try:
348348
self.watcher._changes.append(('__livereload__', restart_delay))
349349
LiveReloadHandler.start_tasks()
350-
add_reload_hook(lambda: IOLoop.instance().close(all_fds=True))
350+
# When autoreload is triggered, initiate a shutdown of the IOLoop
351+
add_reload_hook(lambda: IOLoop.instance().stop())
352+
# The call to start() does not return until the IOLoop is stopped.
351353
IOLoop.instance().start()
354+
# Once the IOLoop is stopped, the IOLoop can be closed to free resources
355+
IOLoop.current().close(all_fds=True)
352356
except KeyboardInterrupt:
353357
logger.info('Shutting down...')
354358

0 commit comments

Comments
 (0)