Ticket #27954: dbshell-postgres-sigint.patch

File dbshell-postgres-sigint.patch, 1.2 KB (added by Chris Sinchok, 8 years ago)

Sample fix

  • django/db/backends/postgresql/client.py

    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  
    11import os
     2import signal
    23import subprocess
    34
    45from django.core.files.temp import NamedTemporaryFile
    class DatabaseClient(BaseDatabaseClient):  
    5455                    # If the current locale can't encode the data, we let
    5556                    # the user input the password manually.
    5657                    pass
     58            existing_handler = signal.getsignal(signal.SIGINT)
     59            signal.signal(signal.SIGINT, lambda sig, frame: None)
    5760            subprocess.check_call(args)
    5861        finally:
     62            signal.signal(signal.SIGINT, existing_handler)
    5963            if temp_pgpass:
    6064                temp_pgpass.close()
    6165                if 'PGPASSFILE' in os.environ:  # unit tests need cleanup
Back to Top