python-postgres / be

pg-python: Execute Python 3 code from PostgreSQL functions.
Other
5 stars 2 forks source link

Interrupting Procedures #13

Closed jwp closed 14 years ago

jwp commented 14 years ago

Not even sure where to begin. It will likely involve a couple mailing lists.

jwp commented 14 years ago

void Py_AddPendingCall(int (func)(void , void *arg))

Looks promising.

jwp commented 14 years ago

http://gist.github.com/305461

Kinda sick. Py_AddPendingCall is a great tool for implementing interrupts, but I think it will still require the signal handler to be overridden..

jwp commented 14 years ago

Signal handler works better, and is generally less hacky, but nonetheless a bit discomforting as this is probably the only PLX to do so.

jwp commented 14 years ago

Py_AddPendingCall isn't the solution because it's not really designed to be chained. that is, it required that the ticker be adjusted after setting it so that it would not be immediately called again after the callback exited.

jwp commented 14 years ago

After a lot of painful debugging, the current master supports interrupts and there are tests to prove it. While working on this, it would appear that some refactoring of error.c will be necessary to better accommodate for the "it can fail here too" places. Ran into a lot of cases where CFI() got ran where I didn't expect it to. Notably, while building out errcontext() in a PG_CATCH() block.

Potential "problem" is that KeyboardInterrupt is not raised. This may need to change, but I'm not sure.