Skip to content

Commit

Permalink
Handle finalization order earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
mobiusklein committed Jun 12, 2024
1 parent e053817 commit 1da9fd0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/ms_deisotope/data_source/thermo_raw_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,14 +693,17 @@ def __repr__(self):
return "ThermoRawLoader(%r)" % (self.source_file)

def _close_handle(self):
if self._raw_source is not None:
try:
self._raw_source.Dispose()
except TypeError:
# Some versions of pythonnet finalize before all dependent
# objects are destroyed making .NET method calls fail
pass
self._raw_source = None
# Some versions of pythonnet finalize before all dependent
# objects are destroyed making .NET method calls fail
try:
if self._raw_source is not None:
try:
self._raw_source.Dispose()
except TypeError:
pass
except TypeError:
pass
self._raw_source = None

def close(self):
"""Close the underlying file reader."""
Expand Down

0 comments on commit 1da9fd0

Please sign in to comment.