Skip to content

Conversation

@sfinkens
Copy link
Member

I get the following warning when reading bzipped AHI HSD files

Exception ignored in: <function AHIHSDFileHandler.__del__ at 0x7f5fff886200>
Traceback (most recent call last):
  File ".../satpy/readers/ahi_hsd.py", line 409, in __del__
AttributeError: 'NoneType' object has no attribute 'path'

This is because the os module is set to None during interpreter shutdown. From the docs:

del() can be executed during interpreter shutdown. As a consequence, the global variables it needs to access (including other modules) may already have been deleted or set to None

I followed the advice in the docs and registered the cleanup using weakref.finalize.

@mraspaud
Copy link
Member

Looking at the documentation, I don't see it clearly written that weakref.finalize would solve the problem you mention. Could you verify yourself that it does indeed work?

@sfinkens
Copy link
Member Author

Yes, with finalizer the warnings are gone. Did you see that section in the documentation?

A finalizer will never invoke its callback during the later part of the interpreter shutdown when module globals are liable to have been replaced by None.

@mraspaud
Copy link
Member

no, but I'm probably looking in the wrong place :) https://docs.python.org/3/reference/datamodel.html#object.__del__

@sfinkens
Copy link
Member Author

@mraspaud
Copy link
Member

Thanks for the link, I understand what finalize does here, so LGTM! I have to admit I'm a bit disappointed by __del__'s behaviour :) or I don't understand what it is for.

Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants