Considering signal handling in plpython again - Mailing list pgsql-hackers

From Hubert Zhang
Subject Considering signal handling in plpython again
Date
Msg-id CAB0yrek0C9ioVoaTiPUXy4GKzHxuf8aSc3+krCCSK_Emxwf4nQ@mail.gmail.com
Whole thread Raw
Responses Re: Considering signal handling in plpython again  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers
Hi all,

I want to support canceling for a plpython query which may be a busy loop.

I found some discussions on pgsql-hackers 2 years ago. Below is the link.


Mario wrote a patch to fix this problem at that time

The main logic is to register a new signal handler for SIGINT/SIGTERM
and link the old signal handler in the chain.

static void PLy_python_interruption_handler()
{
PyErr_SetString(PyExc_RuntimeError, "test except");
return NULL;
}
static void
PLy_handle_interrupt(int sig)
{
// custom interruption
int added = Py_AddPendingCall(PLy_python_interruption_handler, NULL);
if (coreIntHandler) {
(*coreIntHandler)(sig);
}
}


Does anyone have some comments on this patch?
As for me, I think handler function should call PyErr_SetInterrupt() instead of PyErr_SetString(PyExc_RuntimeError, "test except");

--
Thanks

Hubert Zhang

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Needless additional partition check in INSERT?
Next
From: Amit Langote
Date:
Subject: Re: Needless additional partition check in INSERT?