File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,10 @@ PyObject *PLy_interp_globals = NULL;
74
74
/* this doesn't need to be global; use PLy_current_execution_context() */
75
75
static PLyExecutionContext * PLy_execution_contexts = NULL ;
76
76
77
+ /* postgres backend handler for interruption */
78
+ static pqsigfunc coreIntHandler = 0 ;
79
+ static void PLy_handle_interrupt (int sig );
80
+
77
81
78
82
void
79
83
_PG_init (void )
@@ -166,6 +170,9 @@ PLy_initialize(void)
166
170
if (PyErr_Occurred ())
167
171
PLy_elog (FATAL , "untrapped error in initialization" );
168
172
173
+ // Catch and process signals
174
+ coreIntHandler = pqsignal (SIGINT , PLy_handle_interrupt );
175
+
169
176
init_procedure_caches ();
170
177
171
178
explicit_subtransactions = NIL ;
@@ -454,3 +461,22 @@ PLy_pop_execution_context(void)
454
461
MemoryContextDelete (context -> scratch_ctx );
455
462
PLy_free (context );
456
463
}
464
+
465
+ static void
466
+ PLy_python_interruption_handler ()
467
+ {
468
+ PyErr_SetString (PyExc_RuntimeError , "test except" );
469
+ return NULL ;
470
+ }
471
+
472
+ static void
473
+ PLy_handle_interrupt (int sig )
474
+ {
475
+ // custom interruption
476
+ int added = Py_AddPendingCall (PLy_python_interruption_handler , NULL );
477
+
478
+ if (coreIntHandler ) {
479
+ (* coreIntHandler )(sig );
480
+ }
481
+ }
482
+
You can’t perform that action at this time.
0 commit comments