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):

View File

@ -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();

View File

@ -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)