Heikki Linnakangas <hlinn...@iki.fi> writes: > It would be nice to have a solution for this in plpython itself, so that > the query cancel was turned into a Python exception. Patches for that > would be welcome. I think you could use Py_AddPendingCall() from > PostgreSQL's signal handler, to schedule a call to a function that in > turn throws a Python exception.
Py_AddPendingCall is safe to call from a signal handler? That would be ... quite remarkable. I should think it'd at least need to do a malloc(). Also, seeing that it's documented as part of Python threading, I wonder whether we can call it at all without the backend becoming multithreaded. > That'll need some changes to > PostgreSQL's normal signal handlers, like die() and > StatementCancelHandler() in postgres.c, but it seems doable. I'm not in principle averse to letting extensions get control in the signal handlers, but I'm afraid that any such feature would mostly act as a magnet for unsafe coding. regards, tom lane -- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers