{
std::size_t ii(0);
// this part does nothing except to be sure that in notify key all will be OK.
+ PyObject *args(PyTuple_New(1));
+ PyTuple_SetItem(args,0,keyObj); Py_XINCREF(keyObj);
for(std::list< KeyWaiter *>::iterator it=_waiting_keys.begin();it!=_waiting_keys.end();it++,ii++)
{
PyObject *waitKey((*it)->getKeyPyObj());
- PyObject *res(PyObject_CallMethodObjArgs(keyObj, PyUnicode_DecodeASCII("__ne__", 6, NULL), waitKey));
+ PyObject *meth(PyObject_GetAttrString(keyObj,"__eq__"));
+ if(!meth)
+ {
+ std::ostringstream oss; oss << "DataScopeServerTransaction::pingKey : for object id #" << ii << " no __eq__ in pyobj !";
+ throw Exception(oss.str());
+ }
+ PyObject *res(PyObject_CallObject(meth,args));
+ Py_XDECREF(meth);
if(res==NULL)
{
std::ostringstream oss; oss << "DataScopeServerTransaction::pingKey : for object id #" << ii << " error during cmp(k,wk[i]) !";
throw Exception(oss.str());
}
- PyLong_AsLong(res); // res is bool, but it s ok since __int__ is called
+ PyBool_Check(res);
if(PyErr_Occurred())
{
std::ostringstream oss; oss << "DataScopeServerTransaction::pingKey : for object id #" << ii << " error during interpretation of cmp(k,wk[i]) !";
}
Py_XDECREF(res);
}
+ Py_XDECREF(args);
}
void DataScopeServerTransaction::notifyKey(const std::string& varName, PyObject *keyObj, PyObject *valueObj)
{
std::size_t ii(0);
+ PyObject *args(PyTuple_New(1));
+ PyTuple_SetItem(args,0,keyObj); Py_XINCREF(keyObj);
std::list< KeyWaiter *> newList,listOfEltToWakeUp;
for(std::list< KeyWaiter *>::iterator it=_waiting_keys.begin();it!=_waiting_keys.end();it++,ii++)
{
continue;
}
PyObject *waitKey((*it)->getKeyPyObj());
- PyObject *res(PyObject_CallMethodObjArgs(keyObj, PyUnicode_DecodeASCII("__ne__", 6, NULL), waitKey));
- if(res==NULL)
- {
- std::ostringstream oss; oss << "DataScopeServerTransaction::notifyKey : MAIN INTERNAL ERROR ! for object id #" << ii << " error during cmp(k,wk[i]) !";
- throw Exception(oss.str());
- }
- long resCpp(PyLong_AsLong(res)); // res is bool, but it s ok since __int__ is called
+ PyObject *meth(PyObject_GetAttrString(keyObj,"__eq__"));
+ if(!meth)
+ {
+ std::ostringstream oss; oss << "DataScopeServerTransaction::pingKey : for object id #" << ii << " no __eq__ in pyobj !";
+ throw Exception(oss.str());
+ }
+ PyObject *res(PyObject_CallObject(meth,args));
+ Py_XDECREF(meth);
+ if(!PyBool_Check(res))
+ {
+ std::ostringstream oss; oss << "DataScopeServerTransaction::pingKey : for object id #" << ii << " no __eq__ in pyobj !";
+ throw Exception(oss.str());
+ }
if(PyErr_Occurred())
{
std::ostringstream oss; oss << "DataScopeServerTransaction::notifyKey : MAIN INTERNAL ERROR ! for object id #" << ii << " error during interpretation of cmp(k,wk[i]) !";
throw Exception(oss.str());
}
- Py_XDECREF(res);
- if(resCpp==0)
+ if(res==Py_True)
listOfEltToWakeUp.push_back(*it);
else
newList.push_back(*it);
+ Py_XDECREF(res);
}
+ Py_XDECREF(args);
for(std::list< KeyWaiter *>::iterator it=listOfEltToWakeUp.begin();it!=listOfEltToWakeUp.end();it++)
(*it)->valueJustCome(valueObj);
for(std::list< KeyWaiter *>::iterator it=listOfEltToWakeUp.begin();it!=listOfEltToWakeUp.end();it++)
proc = subprocess.Popen(["python3", fname], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out,err=proc.communicate()
if proc.returncode!=0:
+ print("-------------- work -----------")
print(out)
print(err)
+ print("~~~~~~~~~~~~~~ work ~~~~~~~~~~~")
return proc.returncode
def func_test7(scopeName,l,l2,cv):
nbProc=8
pool=mp.Pool(processes=nbProc)
asyncResult=pool.map_async(work,[(i,varName,scopeName) for i in range(nbProc)])
+ print("asyncResult=", asyncResult)
self.assertEqual(asyncResult.get(),nbProc*[0]) # <- the big test is here !
dsm.removeDataScope(scopeName)
wk.waitFor()
self.assertEqual(str2Obj(dss.waitForMonoThrRev(wk)),[7,8,9,10])
keys=[str2Obj(elt) for elt in dss.getAllKeysOfVarWithTypeDict(varName)]
- self.assertEqual(keys,['ab','cd'])
+ self.assertEqual(set(keys),set(['ab','cd']))
def testTransaction6(self):
""" Test to test RdWr global vars with transaction"""