From 9de217fbeb1114df925f9f64aefa4a28caf9bb17 Mon Sep 17 00:00:00 2001 From: "Gajowniczek, Artur" Date: Thu, 25 Jul 2024 08:42:34 -0400 Subject: [PATCH] use METH_O in shutdown_engine --- cpp/csp/python/PyAdapterManager.cpp | 8 ++------ cpp/csp/python/PyEngine.h | 15 --------------- cpp/csp/python/PyPushInputAdapter.cpp | 11 ++++++++++- cpp/csp/python/PyPushPullInputAdapter.cpp | 11 ++++++++++- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/cpp/csp/python/PyAdapterManager.cpp b/cpp/csp/python/PyAdapterManager.cpp index 367fc4bf4..d6547e135 100644 --- a/cpp/csp/python/PyAdapterManager.cpp +++ b/cpp/csp/python/PyAdapterManager.cpp @@ -68,13 +68,9 @@ class PyAdapterManager : public AdapterManager static PyObject * PyAdapterManager_PyObject_starttime( PyAdapterManager_PyObject * self ) { return toPython( self -> manager -> starttime() ); } static PyObject * PyAdapterManager_PyObject_endtime( PyAdapterManager_PyObject * self ) { return toPython( self -> manager -> endtime() ); } -static PyObject * PyAdapterManager_PyObject_shutdown_engine( PyAdapterManager_PyObject * self, PyObject * args, PyObject * kwargs ) +static PyObject * PyAdapterManager_PyObject_shutdown_engine( PyAdapterManager_PyObject * self, PyObject * pyException ) { CSP_BEGIN_METHOD; - - PyObject * pyException; - if( !PyArg_ParseTuple( args, "O", &pyException ) ) - return NULL; self -> manager -> rootEngine() -> shutdown( PyEngine_shutdown_make_exception( pyException ) ); @@ -98,7 +94,7 @@ static int PyAdapterManager_init( PyAdapterManager_PyObject *self, PyObject *arg static PyMethodDef PyAdapterManager_methods[] = { { "starttime", (PyCFunction) PyAdapterManager_PyObject_starttime, METH_NOARGS, "starttime" }, { "endtime", (PyCFunction) PyAdapterManager_PyObject_endtime, METH_NOARGS, "endtime" }, - { "shutdown_engine", (PyCFunction) PyAdapterManager_PyObject_shutdown_engine, METH_VARARGS, "shutdown_engine" }, + { "shutdown_engine", (PyCFunction) PyAdapterManager_PyObject_shutdown_engine, METH_O, "shutdown_engine" }, {NULL} }; diff --git a/cpp/csp/python/PyEngine.h b/cpp/csp/python/PyEngine.h index 6c8dee3a7..d58289501 100644 --- a/cpp/csp/python/PyEngine.h +++ b/cpp/csp/python/PyEngine.h @@ -70,21 +70,6 @@ inline std::exception_ptr PyEngine_shutdown_make_exception( PyObject * pyExcepti return std::make_exception_ptr( PythonPassthrough( pyException ) ); } -// Generic engine shutdown function for push-type adapters -template -PyObject * PyEngine_shutdown( T * self, PyObject * args, PyObject * kwargs ) -{ - CSP_BEGIN_METHOD; - - PyObject * pyException; - if( !PyArg_ParseTuple( args, "O", &pyException ) ) - return NULL; - - self -> adapter -> rootEngine() -> shutdown( PyEngine_shutdown_make_exception( pyException ) ); - - CSP_RETURN_NONE; -} - }; #endif diff --git a/cpp/csp/python/PyPushInputAdapter.cpp b/cpp/csp/python/PyPushInputAdapter.cpp index a9b01b446..cd034844a 100644 --- a/cpp/csp/python/PyPushInputAdapter.cpp +++ b/cpp/csp/python/PyPushInputAdapter.cpp @@ -198,12 +198,21 @@ struct PyPushInputAdapter_PyObject CSP_RETURN_NONE; } + static PyObject * shutdown_engine( PyPushInputAdapter_PyObject * self, PyObject * pyException ) + { + CSP_BEGIN_METHOD; + + self -> adapter -> rootEngine() -> shutdown( PyEngine_shutdown_make_exception( pyException ) ); + + CSP_RETURN_NONE; + } + static PyTypeObject PyType; }; static PyMethodDef PyPushInputAdapter_PyObject_methods[] = { { "push_tick", (PyCFunction) PyPushInputAdapter_PyObject::pushTick, METH_VARARGS, "push new tick" }, - { "shutdown_engine", (PyCFunction) PyEngine_shutdown, METH_VARARGS, "shutdown_engine" }, + { "shutdown_engine", (PyCFunction) PyPushInputAdapter_PyObject::shutdown_engine, METH_O, "shutdown_engine" }, {NULL} }; diff --git a/cpp/csp/python/PyPushPullInputAdapter.cpp b/cpp/csp/python/PyPushPullInputAdapter.cpp index 0f4ee5de9..71190660c 100644 --- a/cpp/csp/python/PyPushPullInputAdapter.cpp +++ b/cpp/csp/python/PyPushPullInputAdapter.cpp @@ -119,13 +119,22 @@ struct PyPushPullInputAdapter_PyObject CSP_RETURN_NONE; } + static PyObject * shutdown_engine( PyPushPullInputAdapter_PyObject * self, PyObject * pyException ) + { + CSP_BEGIN_METHOD; + + self -> adapter -> rootEngine() -> shutdown( PyEngine_shutdown_make_exception( pyException ) ); + + CSP_RETURN_NONE; + } + static PyTypeObject PyType; }; static PyMethodDef PyPushPullInputAdapter_PyObject_methods[] = { { "push_tick", (PyCFunction) PyPushPullInputAdapter_PyObject::pushTick, METH_VARARGS, "push new tick" }, { "flag_replay_complete", (PyCFunction) PyPushPullInputAdapter_PyObject::flagReplayComplete, METH_VARARGS, "finish replay ticks" }, - { "shutdown_engine", (PyCFunction) PyEngine_shutdown, METH_VARARGS, "shutdown engine" }, + { "shutdown_engine", (PyCFunction) PyPushPullInputAdapter_PyObject::shutdown_engine, METH_O, "shutdown engine" }, {NULL} };