diff options
author | Mark Spruiell <mes@zeroc.com> | 2017-03-08 15:47:34 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2017-03-08 15:47:34 -0800 |
commit | fc32c2a7805365e7f40ab8a664f94efae35137da (patch) | |
tree | 9004df864027bfef52218772e88357e01d9bdf0c /python/modules/IcePy/Thread.cpp | |
parent | Refreshed Ice::optional (diff) | |
download | ice-fc32c2a7805365e7f40ab8a664f94efae35137da.tar.bz2 ice-fc32c2a7805365e7f40ab8a664f94efae35137da.tar.xz ice-fc32c2a7805365e7f40ab8a664f94efae35137da.zip |
- ICE-6845 - More dispatcher fixes for Python
- Deprecated the InitializationData.threadHook member
- Added threadStart and threadStop members to InitializationData
- InitializationData.batchRequestInterceptor can now be a callable
Diffstat (limited to 'python/modules/IcePy/Thread.cpp')
-rw-r--r-- | python/modules/IcePy/Thread.cpp | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/python/modules/IcePy/Thread.cpp b/python/modules/IcePy/Thread.cpp index 004e209c3d0..06f100200a3 100644 --- a/python/modules/IcePy/Thread.cpp +++ b/python/modules/IcePy/Thread.cpp @@ -35,10 +35,12 @@ IcePy::AdoptThread::~AdoptThread() PyGILState_Release(_state); } -IcePy::ThreadHook::ThreadHook(PyObject* threadNotification) : - _threadNotification(threadNotification) +IcePy::ThreadHook::ThreadHook(PyObject* threadNotification, PyObject* threadStart, PyObject* threadStop) : + _threadNotification(threadNotification), _threadStart(threadStart), _threadStop(threadStop) { Py_INCREF(threadNotification); + Py_INCREF(threadStart); + Py_INCREF(threadStop); } void @@ -46,10 +48,22 @@ IcePy::ThreadHook::start() { AdoptThread adoptThread; // Ensure the current thread is able to call into Python. - PyObjectHandle tmp = PyObject_CallMethod(_threadNotification.get(), STRCAST("start"), 0); - if(!tmp.get()) + if(_threadNotification.get()) { - throwPythonException(); + PyObjectHandle tmp = PyObject_CallMethod(_threadNotification.get(), STRCAST("start"), 0); + if(!tmp.get()) + { + throwPythonException(); + } + } + if(_threadStart.get()) + { + PyObjectHandle args = PyTuple_New(0); + PyObjectHandle tmp = PyObject_Call(_threadStart.get(), args.get(), 0); + if(!tmp.get()) + { + throwPythonException(); + } } } @@ -58,15 +72,21 @@ IcePy::ThreadHook::stop() { AdoptThread adoptThread; // Ensure the current thread is able to call into Python. - PyObjectHandle tmp = PyObject_CallMethod(_threadNotification.get(), STRCAST("stop"), 0); - if(!tmp.get()) + if(_threadNotification.get()) { - throwPythonException(); + PyObjectHandle tmp = PyObject_CallMethod(_threadNotification.get(), STRCAST("stop"), 0); + if(!tmp.get()) + { + throwPythonException(); + } + } + if(_threadStop.get()) + { + PyObjectHandle args = PyTuple_New(0); + PyObjectHandle tmp = PyObject_Call(_threadStop.get(), args.get(), 0); + if(!tmp.get()) + { + throwPythonException(); + } } -} - -PyObject* -IcePy::ThreadHook::getObject() -{ - return _threadNotification.get(); } |