#27954 closed Cleanup/optimization (fixed)
Prevent PostgreSQL dbshell from exiting on CTRL-C
| Reported by: | Chris Sinchok | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | 1.10 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I love to use dbshell, but have a nitpick with how it works for Postgres. When I'm using psql normally, I use ctrl-c to cancel a query, or to just reset the prompt. However, when I CTRL-C within dbshell, it throws a KeyboardInterrupt.
Perhaps we could override the SIGINT handler directly before launching the psql subprocess, and restore the handler in the finally block? I will attach a sample patch.
Attachments (1)
Change History (6)
by , 9 years ago
| Attachment: | dbshell-postgres-sigint.patch added |
|---|
comment:1 by , 9 years ago
| Component: | Database layer (models, ORM) → Core (Management commands) |
|---|---|
| Has patch: | set |
| Needs tests: | set |
| Summary: | PostgreSQL dbshell exits on CTRL-C → Prevent PostgreSQL dbshell from exiting on CTRL-C |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → Cleanup/optimization |
I haven't look at the code in detail but solving the problem seems reasonable. Perhaps a test may be feasible with mocking?
comment:2 by , 9 years ago
I was able to mock out the behavior, so I wrote a failing test.
I've opened a PR here: https://github.com/django/django/pull/8248
comment:3 by , 9 years ago
| Needs tests: | unset |
|---|
Sample fix