cleanup and inithook
This commit is contained in:
@ -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,
|
||||
|
@ -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()
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user