8000 fix(#170): wait for the IOLoop to be stopped before attempting to clo… · lepture/python-livereload@5453629 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5453629

Browse files
committed
fix(#170): wait for the IOLoop to be stopped before attempting to close it.
1 parent 62d016a commit 5453629

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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)
0