diff --git a/devsupApp/src/dbapi.c b/devsupApp/src/dbapi.c index bff2e7f..8cd3c0c 100644 --- a/devsupApp/src/dbapi.c +++ b/devsupApp/src/dbapi.c @@ -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, diff --git a/devsupApp/src/devsup/__init__.py b/devsupApp/src/devsup/__init__.py index b345cde..dd8da5a 100644 --- a/devsupApp/src/devsup/__init__.py +++ b/devsupApp/src/devsup/__init__.py @@ -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() diff --git a/devsupApp/src/devsup/db.py b/devsupApp/src/devsup/db.py index 996df5b..b0a5605 100644 --- a/devsupApp/src/devsup/db.py +++ b/devsupApp/src/devsup/db.py @@ -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: diff --git a/devsupApp/src/devsup/test/test_db.py b/devsupApp/src/devsup/test/test_db.py index 811292a..0ab6247 100644 --- a/devsupApp/src/devsup/test/test_db.py +++ b/devsupApp/src/devsup/test/test_db.py @@ -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): diff --git a/pyIocApp/setup.c b/pyIocApp/setup.c index b5197fa..6d02940 100644 --- a/pyIocApp/setup.c +++ b/pyIocApp/setup.c @@ -30,9 +30,6 @@ static void cleanupPy(void *junk) PyEval_RestoreThread(state); - /* special "fake" hook for shutdown */ - //pyhook((initHookState)9999); - if(PyRun_SimpleString("import devsup\n" "devsup._fini(iocMain=True)\n" )) { @@ -117,8 +114,6 @@ static void setupPyPath(void) static void pySetupReg(void) { - PyGILState_STATE state; - Py_Initialize(); PyEval_InitThreads(); diff --git a/testApp/test3.py b/testApp/test3.py index fbe1cca..2b275ca 100644 --- a/testApp/test3.py +++ b/testApp/test3.py @@ -27,11 +27,7 @@ class WfSup(object): x=self.x[:N] # calculate inplace: uniform(0.5,2.0)*sin(pha*x)+2 - val[:] = x - val[:] *= pha - np.sin(val, out=val) - val[:]*=uniform(0.5,2.0) - val[:]+=2 + val[:] = np.sin(x*pha)*uniform(0.5,2.0) + 2 self.fld.putarraylen(N)