ADIOS icon indicating copy to clipboard operation
ADIOS copied to clipboard

Python: wrapper of adios.File close errors

Open liangwang0734 opened this issue 3 years ago • 0 comments

  • Wrapping over adios.File might not be a designed usage but would be convenient for user-specific data.
  • Currently, upon file closing errors are occasionally thrown:
# '1.13.1'
print(adios.__version__)

# occasionally throws
class adiosFileWrapper(adios.File):
  pass

# occasionally throws
# class adiosFileWrapper1(adios.File):
#   def __init__(self, name, **kwargs):
#        super(adiosFileWrapper_noDel, self).__init__(name, **kwargs)
#        pass

# occasionally throws
# class adiosFileWrapper2(adios.File):
#     def __init__(self, name, **kwargs):
#         super(adiosFileWrapper_hasDel, self).__init__(name, **kwargs)
#         pass
#
#     def __del__(self):
#         super(adiosFileWrapper_hasDel, self).__del__()

# does not seem to throw, but perhaps insecure (raw file handler might be dangling)
# class adiosFileWrapper3(adios.File):
#     def __init__(self, name, **kwargs):
#         super(adiosFileWrapper_hasDel, self).__init__(name, **kwargs)
#         pass
#   
#     def __del__(self):
#         pass
    
filename = 'test.bp'

# occasionally throws
file = adiosFileWrapper(filename)
file.close()

# fine
file = adios.File(filename)
file.close()

Errors emitted from adiosFileWrapper:

Exception ignored in: <built-in method __del__ of adiosFileWrapper object at 0x7f86a21bead0>
Traceback (most recent call last):
  File "adios.pyx", line 1066, in adios.file.__del__
  File "adios.pyx", line 1078, in adios.file.close
AssertionError: Not an open file

Possibly relevant code:

# adios.File __dell__ method
    def __del__(self):
        """ Close file on destruction. """
        if self.fp != NULL:
            self.close()
  • Why the errors show up only in wrappers not original adios.File?

liangwang0734 avatar Sep 11 '20 18:09 liangwang0734