Skip to content

Conversation

@exarkun
Copy link
Contributor

@exarkun exarkun commented Jun 28, 2022

This is an attempt to further mitigate #479. It probably cannot be said that this fixes that issue because any other __del__, weakref callback, or signal handler could still introduce an import at a bad time.

Still, maybe it is worth having until CPython does something about the underlying issue. The change does mean ResourceWarning reporting by pytest will be lost. I don't think that's a big deal because I don't think anyone is paying attention to that information right now anyway (if we wanted GridSync to be ResourceWarning-free then I expect we would add a CI job that configures a warnings filter like "error::ResourceWarning" and this should also avoid the CPython bug).

Also included here is a change to PYTHONDONTWRITEBYTECODE so that it is set consistently for all platforms when using tox instead of only being set for Windows. It was set for Windows because it managed to mitigate the CPython bug but it did so in a more fragile way than this warnings reconfiguration (I think) but it is a pretty reasonable thing to set anyway since pyc files mostly add complexity.

exarkun added 3 commits June 28, 2022 09:24
Linux and macOS can appreciate the simplicity of having no pyc files just as
much as Windows.
CPython makes ResourceWarning off by default but pytest turns it on by default
so we supply pytest configuration to turn it off again.

This should mitigate the CPython bug because ignored warnings are detected
before the warnings module does any imports (and they are handled by exiting
early so the imports never happen).
@crwood crwood merged commit fb2de3b into gridsync:master Jun 28, 2022
@crwood
Copy link
Member

crwood commented Jun 28, 2022

Thank you!

@exarkun exarkun deleted the 479.importlib-bug-workaround branch June 28, 2022 14:33
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