Repository navigation
fix(cli): delete dev endpoints when rp flash dev is stopped by a signal - #625
Draft
justinwlin wants to merge 1 commit into
Draft
justinwlin wants to merge 1 commit into
justinwlin wants to merge 1 commit into
Conversation
A dev session started in the background from a non-interactive shell inherits SIGINT as ignored, so Python never raises KeyboardInterrupt, and SIGTERM has no handler. Either way the process stopped without its teardown and left the session's endpoints running and billing. A stop during a long entrypoint call also waited for that call indefinitely. Install SIGINT and SIGTERM handlers on the session loop. The first signal cancels the session, which runs teardown and deletes the endpoints. A second signal stops waiting for a running entrypoint. The entrypoint thread is a daemon and tolerates the loop closing under it.
| # an abandoned entrypoint's error is not retrieved | ||
| done.add_done_callback(lambda f: f.cancelled() or f.exception()) | ||
| else: | ||
| await done |
| # an abandoned entrypoint's error is not retrieved | ||
| done.add_done_callback(lambda f: f.cancelled() or f.exception()) | ||
| else: | ||
| await done |
This branch has not been deployed
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.
Stopping
rp flash devwith a signal left its endpoints running and billing. An agent's dev loop hits this every time: it starts the session in the background and stops it withkill.Cause
KeyboardInterrupthandler, and asyncio doesn't add its own, sokill -INTdoes nothing.runpod-flash cleaned up on
KeyboardInterruptin its CLI.Change
Verification
rp flash dev main.py < /dev/null &from a script, thenkill -TERMand separatelykill -INTafter the first run. Both exited with✓ cleaning up 1 deleted, and a GraphQL endpoint list showed nothing left.Event loop is closedfrom the abandoned thread, which this change fixes. Each passed three consecutive runs.pytest tests: 1482 passed, coverage 91.64%.