Skip to content

Commit

Permalink
use METH_O in shutdown_engine
Browse files Browse the repository at this point in the history
  • Loading branch information
argaj committed Jul 25, 2024
1 parent 7388bff commit 9de217f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
8 changes: 2 additions & 6 deletions cpp/csp/python/PyAdapterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );

Expand All @@ -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}
};

Expand Down
15 changes: 0 additions & 15 deletions cpp/csp/python/PyEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
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
11 changes: 10 additions & 1 deletion cpp/csp/python/PyPushInputAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PyPushInputAdapter_PyObject>, METH_VARARGS, "shutdown_engine" },
{ "shutdown_engine", (PyCFunction) PyPushInputAdapter_PyObject::shutdown_engine, METH_O, "shutdown_engine" },
{NULL}
};

Expand Down
11 changes: 10 additions & 1 deletion cpp/csp/python/PyPushPullInputAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PyPushPullInputAdapter_PyObject>, METH_VARARGS, "shutdown engine" },
{ "shutdown_engine", (PyCFunction) PyPushPullInputAdapter_PyObject::shutdown_engine, METH_O, "shutdown engine" },
{NULL}
};

Expand Down

0 comments on commit 9de217f

Please sign in to comment.