Conversation
Marinski
force-pushed
the
fix/mt5client-wedge
branch
from
October 2, 2026 08:54
d28fbef to
63be1a8
Compare
…ng the API A timed-out SDK call leaves its worker thread inside the SDK, and the global lock then lets the next request call in beside it; each later hang leaks another thread until waitress's queue saturates and even /ping takes an hour (2026-08-23). - Instrument: live SDK worker count and oldest age on /ping; every TIMEOUT/WEDGED log line carries mode, path and worker count. - Single-flight guard: while a timed-out call is still inside the SDK, new calls raise MT5Wedged (503 + Retry-After) instead of starting a thread. restart_terminal's own reconnect is exempt. - Wedge watchdog thread in every mode: exit the process (code 75) once a worker has been stuck MT5_WEDGE_EXIT_SECONDS (180 s), deferring while a backtest holds RUN_LOCK, up to a 30 min ceiling. - restart_terminal skips mt5.shutdown while wedged. The relaunch loop that brings an exited process back is a local api_runner.bat hook applied by the backtester's deploy-mt5-scripts.sh.
config.yaml accounts can carry extra keys (the backtest manager's symbol_map); init_mt5(**account) raised TypeError on them, so every SDK route on such an account returned 500.
Marinski
force-pushed
the
fix/mt5client-wedge
branch
from
October 2, 2026 09:01
63be1a8 to
67e2bf4
Compare
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.
Fixes #23.
MT5Wedged(503 +Retry-After) instead of spawning another thread;restart_terminal's own reconnect is exempt./pingreports the live SDK worker count and oldest age; every TIMEOUT/WEDGED line carries mode, path and worker count.MT5_WEDGE_EXIT_SECONDS(180 s), deferring while a backtest holdsRUN_LOCK, up to a 30 min ceiling.restart_terminalskipsmt5.shutdownwhile wedged.init_mt5— a config account carrying extra keys otherwiseTypeErrors and every SDK route on it returns 500.Tests:
tests/test_wedge_watchdog.py, plus addedtests/test_mt5client.pycases.