Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handles SIGINT (Ctr-C) and gracefully stops an inflight request. #134

Merged
merged 1 commit into from
Jun 8, 2022

Conversation

yfuruyama
Copy link
Collaborator

Currently spanner-cli doesn't handle SIGINT, so if it receives SIGINT in response to the Ctrl-C, the CLI is killed suddenly and inflight request is not canceled properly.

This PR handles the SIGINT properly for both interactive mode and batch mode. This PR also removes the Session.ctx field, which was not used effectively at this moment.

More background: #133

Example

Interactive mode

spanner> SELECT COUNT(*) FROM t1;
^CERROR: spanner: code = "Canceled", desc = "context canceled"

Batch mode

spanner-cli -p <PROJECT> -i <INSTANCE> -d <DATABASE> -e 'SELECT COUNT(*) FROM t1;'
^CERROR: spanner: code = "Canceled", desc = "context canceled

@yfuruyama
Copy link
Collaborator Author

@apstndb Could you take a look at this PR when you have a chance? (cc: @nielm)

@yfuruyama yfuruyama requested a review from apstndb June 8, 2022 00:58
Copy link
Collaborator

@apstndb apstndb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yfuruyama
Copy link
Collaborator Author

Thanks @apstndb for the review!

@yfuruyama yfuruyama merged commit 40e3fe3 into master Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants