- Finish fix for return values in PythonPolicy
- Put mutex and global _ret_val variable into ScriptAdapter instead of the global space, space which is anyway not accessible after decref'ing the corresponding python module git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@527 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
4ab3056c23
commit
8102eb8b7e
|
@ -79,7 +79,7 @@ class ScriptAdapter :
|
|||
#
|
||||
# @param self The caller object
|
||||
def async_is_preemptive(self):
|
||||
_g_mutex.lock(ScriptAdapter._wrap_is_preemptive, self)
|
||||
self._g_mutex.lock(ScriptAdapter._wrap_is_preemptive, self)
|
||||
|
||||
def _wrap_is_preemptive(self):
|
||||
thread.start_new_thread(ScriptAdapter._wrap_is_preemptive_callback, (self,))
|
||||
|
@ -105,5 +105,5 @@ class ScriptAdapter :
|
|||
def get_return_value(self):
|
||||
return self._ret_val
|
||||
|
||||
def test_lock(self):
|
||||
def mutex_test_lock(self):
|
||||
return self._g_mutex.test()
|
||||
|
|
|
@ -131,6 +131,7 @@ PythonPolicy::is_pre_emptive() const throw(UserInterruptException)
|
|||
|
||||
// Parse return value stored in global Python object
|
||||
retval = PyObject_CallMethod(_adapter, "get_return_value", NULL);
|
||||
assert(retval);
|
||||
bool ret = PyObject_IsTrue(retval);
|
||||
Py_DECREF(retval);
|
||||
return ret;
|
||||
|
@ -146,6 +147,7 @@ PythonPolicy::get_time_slice() const throw(UserInterruptException) {
|
|||
|
||||
// Parse return value stored in global Python object
|
||||
retval = PyObject_CallMethod(_adapter, "get_return_value", NULL);
|
||||
assert(retval);
|
||||
long tmp = PyInt_AsLong(retval);
|
||||
Py_DECREF(retval);
|
||||
|
||||
|
@ -167,7 +169,7 @@ PythonPolicy::wait_unlock() const throw(UserInterruptException)
|
|||
usleep(WAIT_FOR); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
|
||||
Py_BLOCK_THREADS;
|
||||
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, "test_lock", NULL);
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, "mutex_test_lock", NULL);
|
||||
assert(retval);
|
||||
still_locked = PyObject_IsTrue(retval);
|
||||
Py_DECREF(retval);
|
||||
|
|
Loading…
Reference in New Issue