Cancelling a query from Python

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>
Subject: Cancelling a query from Python
Date: 2014-07-20 11:19:47
Message-ID: CA+mi_8bpm6u0qwe-h=Zpo2ZF=eo52ij5tijuR1grsCgpJA+ocQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

As you may have experienced, cancelling a long running query from
Python is not easy: ctrl-c doesn't work and it usually takes a
pg_cancel_backend from another connection.

After a request in the bug tracking, here is a recipe to allow queries
to be stopped by a ctrl-c in interactive sessions.

http://initd.org/psycopg/articles/2014/07/20/cancelling-postgresql-statements-python/

Hope it helps.

-- Daniele

Browse psycopg by date

  From Date Subject
Next Message Damian Dimmich 2014-07-22 10:03:47 JSONB marshalling
Previous Message Daniele Varrazzo 2014-07-11 10:09:01 Re: Psycopg2 unable to timeout