Articles from July 2014

« Back to 2014

Cancelling PostgreSQL statements from Python

Posted by Daniele Varrazzo on 2014-07-20
Tagged as recipe

Cancelling a long running query from Python is not something that happens automatically: the libpq doesn't react to Python signals so the only way to stop a query is to run a pg_cancel_backend from another process. Killing the Python process won't cancel the query: it will run until completion and then rolled back. This makes working with long-running query from the Python interpreter somewhat frustrating.