cleanup and inithook

This commit is contained in:
Michael Davidsaver
2018-11-04 16:47:23 -08:00
parent 6b8d7ff7c5
commit 574ca20bdb
6 changed files with 22 additions and 12 deletions

View File

@ -152,6 +152,21 @@ fail:
PyGILState_Release(gilstate);
}
static
PyObject* py_announce(PyObject *unused, PyObject *args, PyObject *kws)
{
static char* names[] = {"state", NULL};
int state;
if(!PyArg_ParseTupleAndKeywords(args, kws, "i", names, &state))
return NULL;
Py_BEGIN_ALLOW_THREADS {
initHookAnnounce((initHookState)state);
} Py_END_ALLOW_THREADS
Py_RETURN_NONE;
}
static
PyObject *py_iocsh(PyObject *unused, PyObject *args, PyObject *kws)
{
@ -237,7 +252,6 @@ PyObject *py_iocInit(PyObject *unused, PyObject *args, PyObject *kws)
static
PyObject *py_pyDevSupCommon(PyObject *unused)
{
static int once;
Py_BEGIN_ALLOW_THREADS {
pyDevSupCommon_registerRecordDeviceDriver(pdbbase);
} Py_END_ALLOW_THREADS
@ -246,6 +260,8 @@ PyObject *py_pyDevSupCommon(PyObject *unused)
}
static struct PyMethodDef dbapimethod[] = {
{"initHookAnnounce", (PyCFunction)py_announce, METH_VARARGS|METH_KEYWORDS,
"initHookAnnounce(state)\n"},
{"iocsh", (PyCFunction)py_iocsh, METH_VARARGS|METH_KEYWORDS,
"Execute IOC shell script or command"},
{"dbReadDatabase", (PyCFunction)py_dbReadDatabase, METH_VARARGS|METH_KEYWORDS,

View File

@ -81,4 +81,6 @@ device(aao, INST_IO, pydevsupComOut, "Python Device")
_dbapi._dbd_setup()
def _fini(iocMain=False):
if iocMain:
_dbapi.initHookAnnounce(9999) # our magic/fake AtExit hook
_dbapi._dbd_cleanup()

View File

@ -328,7 +328,7 @@ class Record(_dbapi._Record):
threading.Timer(1.0, record.asyncFinish, kwargs={'reason':AsyncDone})
record.asyncStart()
"""
return _dbapi._Record.asyncStart(self, reason=reason)
return _dbapi._Record.asyncFinish(self, reason=reason)
def __getattr__(self, name):
try:

View File

@ -33,6 +33,7 @@ class IOCHelper(unittest.TestCase):
def tearDown(self):
self.iocShutdown();
print("testdbCleanup()")
_dbapi.initHookAnnounce(9999) # our magic/fake AtExit hook
_dbapi._UTest.testdbCleanup()
def iocInit(self):