feat: Add stop() method to Server for graceful shutdown and IOLoop control#284
Open
maboloshi wants to merge 1 commit intolepture:masterfrom
Open
feat: Add stop() method to Server for graceful shutdown and IOLoop control#284maboloshi wants to merge 1 commit intolepture:masterfrom
maboloshi wants to merge 1 commit intolepture:masterfrom
Conversation
- Added a stop() method to livereload.Server to allow proactive shutdown - Closes all listening HTTP servers and releases bound ports - Uses asyncio_loop.is_running() to check IOLoop state safely - Stops IOLoop via add_callback() to ensure thread-safe termination - Enables better integration with threaded environments
maboloshi
added a commit
to maboloshi/LiveReloadPy
that referenced
this pull request
Jul 10, 2025
• 对 livereload 上游项目添加停止功能补丁 (PR lepture/python-livereload#284) • 在插件中直接调用 server.stop() 方法停止服务 • 移除插件中复杂的 IOLoop 直接操作 • 优化资源清理流程
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ Key Changes:
Server.stop():.listen())IOLoop(which wrapsasyncio) is still running viaself.ioloop.asyncio_loop.is_running()self.ioloop.add_callback(self.ioloop.stop)to safely stop the loop from any threadThread-safe and robust: Designed to work reliably even when livereload is used in non-main threads
No breaking changes: This is an additive change; existing behavior remains untouched unless
.stop()is explicitly called✅ Benefits:
OSError: address already in usewhen restarting livereload