Skip to content

Conversation

rose-m
Copy link
Contributor

@rose-m rose-m commented May 6, 2021

Still a work in progress - but already implements a large deal of CTRL-C handling. The process is as follows:

  1. CTRL-C is caught for an async execution
  2. All MongoClients are closed
  3. We print the "Error: Asynchronous execution was interrupted" message (no prompt)
  4. We wait until the async execution finishes (since it is running in the background CTRL-C doesn't kill it) and silently catch any errors
  5. We reconnect all MongoClients
  6. The prompt returns and allows the user to enter new commands

The following needs to be completed:

  • Adapt the API decorators to check for interruption and immediately throw an internal error
  • Adapt the async-writer to ensure that the internal interrupt errors are not caught by user code

And here a quick demo how it looks like for a simple command:

mongosh-ctrlc

@rose-m rose-m self-assigned this May 6, 2021
Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Looks great so far!

@rose-m rose-m force-pushed the MONGOSH-640-handle-ctrl-c-properly branch 2 times, most recently from 5009b94 to c9e0412 Compare May 7, 2021 12:44
@rose-m rose-m force-pushed the MONGOSH-640-handle-ctrl-c-properly branch from c9e0412 to 8b13806 Compare May 10, 2021 15:25
Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Looks great so far :)

@rose-m rose-m force-pushed the MONGOSH-640-handle-ctrl-c-properly branch from de3e672 to c7e9111 Compare May 12, 2021 09:36
@rose-m rose-m marked this pull request as ready for review May 12, 2021 13:02
@rose-m rose-m force-pushed the MONGOSH-640-handle-ctrl-c-properly branch from 27727ec to 3e211a7 Compare May 17, 2021 14:19
@rose-m rose-m changed the title fix(cli-repl): ctrl-c terminates running DB operations (MONGOSH-640) fix(cli-repl): ctrl-c terminates running DB operations MONGOSH-640 May 18, 2021
@rose-m rose-m merged commit b4ef0f0 into main May 18, 2021
@rose-m rose-m deleted the MONGOSH-640-handle-ctrl-c-properly branch May 18, 2021 07:01
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