Repository navigation
Start the WebSocket manager only after Info metadata initialization succeeds - #349
Open
yutianjiang39 wants to merge 1 commit into
Open
yutianjiang39 wants to merge 1 commit into
yutianjiang39 wants to merge 1 commit into
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.
Info.__init__starts the WebSocket manager before loading metadata. Ifspot_meta()raises, construction fails: the caller never receives anInfoinstance on which to calldisconnect_websocket(). In an offline reproduction against2fdb18f, the real manager thread was still alive after the exception and the fake transport had not been closed.Move manager creation and startup to the end of metadata initialization. A metadata error still propagates, but there is no background WebSocket to clean up. Successful construction still starts the manager once when
skip_wsis false. This change does not alter reconnect or subscription handling.Regression tests:
python -m pytest -o addopts= -q tests/info_websocket_init_test.py. The failure-path test forcesspot_meta()to raise and checks thatstart()was never called. The success-path test supplies metadata locally and checks thatstart()was called once. On the original source the first test failed and the second passed; with this change both passed. Neither test opens a socket or relies on thread timing.