ADIOS2
ADIOS2 copied to clipboard
Python should throw error just like the C++ API when using Variable objects that expired
Users, including us, frequently make the mistake to InquireVariable
outside the BeginStep/EndStep
loop, thinking that it's enough to inquire it once since it does not change. But the engines destruct them in each step and create new ones internally, so InquireVariable must be called in each step to get the valid object.
However, the bindings create and return a stable object that points to this internal object that becomes invalid. The C++ binding takes effort to check the validity and throw an error, but the Python binding does not.
Here we request the Python binding to be fixed and throw/return an error if someone is trying to use a Variable object that has been deleted.
Tests show that in C++ an exception is thrown only if the StreamReader parameter is on. The same exception is thrown in python. In the following code an exception is thrown in the 2nd step.
ioRead.SetParameter("StreamReader", "On")
adEngine = ioRead.Open(bpFilename, adios2.Mode.Read)
varReadMyString = ioRead.InquireVariable(varname)
for step in range(N_STEPS):
adEngine.BeginStep()
result = adEngine.Get(varReadMyString)
adEngine.EndStep()
adEngine.Close()
This test does not run anymore. Will put it into unittests.