Robustness: Handle stale COM objects and RPC server unavailability#57
Open
amirf147 wants to merge 1 commit into
Open
Robustness: Handle stale COM objects and RPC server unavailability#57amirf147 wants to merge 1 commit into
amirf147 wants to merge 1 commit into
Conversation
- Implement exponential backoff retry logic in \_com_retry\ - Ensure RPC errors trigger a refresh of the Managers instance - Prevent RPC errors from being swallowed as NotImplementedError in \_get_object\ - Suppress benign RPC_E_CHANGED_MODE warnings during re-initialization
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 PR addresses issues where
pyvdabecomes unresponsive after a Windows Explorer restart or other events that cause the Virtual Desktop COM objects to become stale.Problem
When Explorer restarts, the underlying COM interfaces for virtual desktops are destroyed and re-created. Any existing pointers held by
pyvdabecome invalid, leading toRPC_S_SERVER_UNAVAILABLEorRPC_E_DISCONNECTEDerrors.Solution
_com_retrydecorator to attempt the failed operation up to 3 times with an exponential backoff.pyvdanow automatically re-initializes its globalmanagersinstance, re-acquiring fresh COM pointers.NotImplementedErrorin_get_object, preventing the retry logic from triggering.RPC_E_CHANGED_MODEwarnings (often triggered when multiple libraries try to initialize COM on the same thread with different modes) to debug logs to reduce noise during recovery.Error Example
Steps to Reproduce
taskkill /f /im explorer.exe && start explorer.exein a terminal).castervoice\lib\windows_virtual_desktops.py:_ctypes.COMError: (-2147023174, 'The RPC server is unavailable.')because theVirtualDesktopCOM object has gone stale following the Explorer restart.