Skip to content

Commit 6191a5a

Browse files
committed
Added a PyErr_CheckSignals() call every time we re-aquire the GIL. this is to ensure we process any pending signals even if not calling into python.
Also have PyEngine return NULL if there is a pending exception ( ie KeyboardInterrupt ) so that it gets raised on return Signed-off-by: Rob Ambalu <robert.ambalu@point72.com>
1 parent ecdef25 commit 6191a5a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

cpp/csp/python/PyEngine.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ void PythonEngine::dialectLockGIL() noexcept
3131
{
3232
PyEval_RestoreThread( m_pyThreadState );
3333
m_pyThreadState = nullptr;
34+
if( PyErr_CheckSignals() == -1 && PyErr_Occurred() )
35+
shutdown();
3436
}
3537

3638
//The engine python wrapper object
@@ -114,7 +116,7 @@ static PyObject * PyEngine_run( PyEngine * self, PyObject * args )
114116
CSP_TRUE_OR_THROW_RUNTIME( self -> engine() -> isRootEngine(), "engine is not root engine" );
115117
self -> rootEngine() -> run( start, end );
116118

117-
return self -> collectOutputs();
119+
return PyErr_Occurred() ? nullptr : self -> collectOutputs();
118120
CSP_RETURN_NONE;
119121
}
120122

0 commit comments

Comments
 (0)