From 642b7b2324c2cdd82e21bddb5c08a47f5dca4e4d Mon Sep 17 00:00:00 2001
From: Chris Sinchok <chris@sinchok.com>
Date: Fri, 17 Mar 2017 11:13:01 -0500
Subject: [PATCH] Overriding sigint handler during psql subprocess
---
django/db/backends/postgresql/client.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py
index 005f43d..1b41267 100644
|
a
|
b
|
|
| 1 | 1 | import os |
| | 2 | import signal |
| 2 | 3 | import subprocess |
| 3 | 4 | |
| 4 | 5 | from django.core.files.temp import NamedTemporaryFile |
| … |
… |
class DatabaseClient(BaseDatabaseClient):
|
| 54 | 55 | # If the current locale can't encode the data, we let |
| 55 | 56 | # the user input the password manually. |
| 56 | 57 | pass |
| | 58 | existing_handler = signal.getsignal(signal.SIGINT) |
| | 59 | signal.signal(signal.SIGINT, lambda sig, frame: None) |
| 57 | 60 | subprocess.check_call(args) |
| 58 | 61 | finally: |
| | 62 | signal.signal(signal.SIGINT, existing_handler) |
| 59 | 63 | if temp_pgpass: |
| 60 | 64 | temp_pgpass.close() |
| 61 | 65 | if 'PGPASSFILE' in os.environ: # unit tests need cleanup |