Re: signal handling in plpython

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: signal handling in plpython
Дата
Msg-id 4878.1476449107@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: signal handling in plpython  (Heikki Linnakangas <hlinnaka@iki.fi>)
Ответы Re: signal handling in plpython  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Heikki Linnakangas <hlinnaka@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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Stats sender and 2pc minor problem
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: PATCH: Batch/pipelining support for libpq