ornladios / ADIOS

The old ADIOS 1.x code repository. Look for ADIOS2 for new repo
https://csmd.ornl.gov/adios
Other
54 stars 40 forks source link

Python: adios.File inheritance gives errors upon __del__ #188

Closed liangwang0734 closed 5 years ago

liangwang0734 commented 5 years ago

Naive empty inheritance

import gc

import adios
class myFile(adios.File):
    pass

for i in range(2):
    fname = "test.bp"
    gc.collect()
    fp = myFile(fname)
    fp.close()

gives errors like

Exception ignored in: <built-in method __del__ of myFile object at 0x2ad0c41f01a8>
Traceback (most recent call last):
  File "adios.pyx", line 1043, in adios.file.__del__ (adios.cpp:15561)
  File "adios.pyx", line 1055, in adios.file.close (adios.cpp:15817)
AssertionError: Not an open file
Exception ignored in: <built-in method __del__ of myFile object at 0x2ad0c41f00f8>
Traceback (most recent call last):
  File "adios.pyx", line 1043, in adios.file.__del__ (adios.cpp:15561)
  File "adios.pyx", line 1055, in adios.file.close (adios.cpp:15817)
AssertionError: Not an open file

No such problem for h5py.File. Any idea?

jychoi-hpc commented 5 years ago

There was a double-close problem. I just added a line to check if the file is already closed or not.

I pushed the fix and updated pypi too. Can you try with the most recent version?

liangwang0734 commented 5 years ago

Thank you jy. I saw many diffs in cxx files. I'm using a Conda wheel version and it is not easy for me to verify for now. But your answer sounds right. Please close this issue if you feel it is solved. I will try to verify this later.