Fix #65176: Auto-terminate live gateway on platform lock conflict - #65218
Closed
AllardQuek wants to merge 1 commit into
Closed
AllardQuek wants to merge 1 commit into
AllardQuek wants to merge 1 commit into
Conversation
AllardQuek
force-pushed
the
fix/platform-lock-auto-terminate-65176
branch
from
July 15, 2026 21:16
96dd0bf to
a1d2683
Compare
…conflict When a new gateway detects a platform lock conflict (e.g. Telegram bot token already in use) and the holder is a live gateway process, it now terminates the holder and retries the lock acquisition instead of retrying indefinitely with a fatal error. This mirrors the --replace behavior but applies it at platform-connect time when the scoped token lock detects a conflict, resolving the issue where the gateway would wait for manual SIGKILL of the conflicting process. Changes: - gateway/platforms/base.py: Modified _acquire_platform_lock() to detect live gateway holders via _looks_like_gateway_process(), write takeover marker, force-terminate with terminate_pid(), wait 0.5s, and retry lock acquisition. Falls back to fatal error only if retry still fails. - tests/gateway/test_platform_lock_auto_terminate.py: New test file with three test cases covering termination of live gateway holders, non-termination of non-gateway holders, and fallback to fatal error when termination fails.
AllardQuek
force-pushed
the
fix/platform-lock-auto-terminate-65176
branch
from
July 15, 2026 21:18
a1d2683 to
dded554
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.
When a new gateway detects a platform lock conflict (e.g. Telegram bot token already in use) and the holder is a live gateway process, it now terminates the holder and retries the lock acquisition instead of retrying indefinitely with a fatal error.
This mirrors the --replace behavior but applies it at platform-connect time when the scoped token lock detects a conflict, resolving the issue where the gateway would wait for manual SIGKILL of the conflicting process.
Changes: