Closed brianmaissy closed 1 year ago
@tk0miya what do you think?
In case anyone else is having the same problem, as a temporary workaround I monkeypatched subprocess.Popen while calling the testing.postgresql.Postgresql() constructor
Personally this is no longer relevant for me, so in the spirit of Closember I am closing. @huytran1ibm or anyone else, feel free to comment if you still want this.
I have a script which uses testing.postgres to create a temporary database to test against. My script has a SIGINT handler which handles teardown logic, which I want to run before the database is terminated.
The problem is that when one presses CTRL+C in a terminal, the shell sends SIGINT to the entire process group, thereby killing the postgres process before my teardown logic can finish running.
The solution I propose is to expose a boolean parameter to the
testing.postgresql.Postgresql()
constructor, which if True, will causestart_new_session=True
to be passed to the call tosubprocess.Popen
in common/database.py, which will cause python to runsetsid()
in the child process before running postgres.I'd be happy to open a PR if something along these lines sounds good to you.