Fixed: stem inconsistencies in the module resolution and rollback loo…#3
Merged
Conversation
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.
This pull request makes significant improvements to the thread-safety, timeout handling, and error notification mechanisms in the
HookRegistryclass. The changes ensure that hook registration, unregistration, and dispatch are safe under concurrent access, improve the reliability of timeout enforcement for synchronous hooks, and enhance plugin error handling, especially for async error callbacks.Thread-safety improvements:
_hooks) are now protected by a reentrant lock (threading.RLock), preventing race conditions when hooks are registered, unregistered, or dispatched from multiple threads. Iteration over hooks now uses a snapshot to avoid concurrent modification issues. [1] [2] [3] [4] [5] [6]Timeout handling improvements:
ThreadPoolExecutorinstead of creating a new one per call. This prevents the main thread from blocking indefinitely if a hook times out, and avoids orphaned worker threads blocking process exit. [1] [2] [3]Plugin error notification:
on_errorcallbacks are now handled more robustly: async error handlers are properly awaited intrigger_async, and in sync mode, async error handlers are closed with a warning to avoid unawaited coroutine warnings. [1] [2] [3] [4] [5]Other improvements:
*now matches only non-empty segments, preventing accidental matches with empty segments.collect_allerror strategy. [1] F64c90f2L447R447, [2]These changes make the hook system safer, more predictable, and easier to debug in concurrent and plugin-heavy environments.…k timeouts