-// Copyright (C) 2012-2016 CEA/DEN, EDF R&D
+// Copyright (C) 2012-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "InlineNode.hxx"
#include "ServiceNode.hxx"
#include "PyStdout.hxx"
-#include "AutoGIL.hxx"
+#include "PythonCppUtils.hxx"
#include "ResourcesManager.hxx"
{
if(_isToSave)
{
- PyThreadState *save(PyThreadState_Swap(NULL));// safe call of PyEval_SaveThread()
- if(save)
- {
- _save=save;
- PyEval_ReleaseLock();
- }
+ _save = PyEval_SaveThread();
}
}
- ~MyAutoThreadSaver() { if(_isToSave) if(_save) { PyEval_AcquireLock(); PyThreadState_Swap(_save); /*safe call of PyEval_RestoreThread*/ } }
+ ~MyAutoThreadSaver() { if(_isToSave) PyEval_RestoreThread(_save); }
private:
bool _isToSave;
PyThreadState *_save;
void YACSEvalYFXGraphGenCluster::generateGraph()
{
- YACS::ENGINE::AutoGIL agil;
+ AutoGIL agil;
//
const char EFXGenFileName[]="EFXGenFileName";
const char EFXGenContent[]="import getpass,datetime,os\nn=datetime.datetime.now()\nreturn os.path.join(os.path.sep,\"tmp\",\"EvalYFX_%s_%s_%s.xml\"%(getpass.getuser(),n.strftime(\"%d%m%y\"),n.strftime(\"%H%M%S\")))";
const char EFXGenContent2[]="import getpass,datetime\nn=datetime.datetime.now()\nreturn \"EvalYFX_%s_%s_%s\"%(getpass.getuser(),n.strftime(\"%d%m%y\"),n.strftime(\"%H%M%S\"))";
//
- YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent));
- YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
+ AutoPyRef func(YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent));
+ AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
if (PyUnicode_Check(val))
_locSchemaFile = PyUnicode_AsUTF8(val);
else
bool YACSEvalYFXGraphGenCluster::go(const YACSEvalExecParams& params, YACSEvalSession *session) const
{
- YACS::ENGINE::AutoGIL agil;
+ AutoGIL agil;
_errors = "";
getUndergroundGeneratedGraph()->saveSchema(_locSchemaFile);
YACSEvalListOfResources *rss(getBoss()->getResourcesInternal());
oss << "f=open(p,\"r\")" << std::endl;
oss << "return eval(f.read())";
std::string zeInput(oss.str());
- YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy("fetch",zeInput));
- YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
+ AutoPyRef func(YACS::ENGINE::evalPy("fetch",zeInput));
+ AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
if(!PyList_Check(val))
throw YACS::Exception("Fetched file does not contain a list !");
Py_ssize_t sz(PyList_Size(val));