Discussion:
query cancellation
Jan Urbański
2010-07-24 21:06:43 UTC
Permalink
Hi,

here's a patch to support query cancellation via
http://www.postgresql.org/docs/8.4/static/libpq-cancel.html

It's based on top of my rollback_on_exit branch in
http://git.wulczer.org/?p=psycopg2.git, simply because I think the first
branch should be merged in first, but they're mostly independent.

You can cancel both synchronous and asynchronous queries, I haven't
tried green queries, but I think they should work too. I'll add support
for this in the Twisted wrapper soon, hopefully using Deferred cancellation.

Cheers,
Jan
Daniele Varrazzo
2010-07-25 00:49:59 UTC
Permalink
Post by Jan Urbański
Hi,
here's a patch to support query cancellation via
http://www.postgresql.org/docs/8.4/static/libpq-cancel.html
It's based on top of my rollback_on_exit branch in
http://git.wulczer.org/?p=psycopg2.git, simply because I think the first
branch should be merged in first, but they're mostly independent.
You can cancel both synchronous and asynchronous queries, I haven't
tried green queries, but I think they should work too. I'll add support
for this in the Twisted wrapper soon, hopefully using Deferred cancellation.
It is also possible to call pg_cancel_backend() [1] from a connection
after you got its pid via get_backend_pid() [2]. You need a second
connection though.

[1] http://www.postgresql.org/docs/8.3/static/functions-admin.html#FUNCTIONS-ADMIN-SIGNAL-TABLE
[2] http://initd.org/psycopg/docs/connection.html#connection.get_backend_pid

-- Daniele

Continue reading on narkive:
Loading...