Open projectgus opened 2 days ago
# Keep a reference to sys.is_finalizing, as sys may have been cleared out
+ # at that point.
+ _is_finalizing=sys.is_finalizing
FWIW I didn't confirm this is necessary, it's copied from the linked PR. It seems like since Python 3.4 and PEP-442 global variables aren't set to None during shutdown any more, so the module may still be accessible the normal way.
This explanation and fix makes sense, can you submit a PR?
I didn't confirm this is necessary
Can you try leaving it out of your patch and running your build a bunch to see if you still get the error? I'd prefer not including patterns that are no longer needed.
This explanation and fix makes sense, can you submit a PR?
Done!
Can you try leaving it out of your patch and running your build a bunch to see if you still get the error? I'd prefer not including patterns that are no longer needed.
Good idea. It seems not necessary here (whereas without the check I see the "Exception ignored" messages 100% of the time.)
Hi!
I think under some circumstances weakref callbacks from blinker 1.8.2 signals raise exceptions during interpreter shutdown, leading to "Exception ignored" errors right on exit. For example:
Context
I'm sorry that I don't have a reproducer for this. I've tried, but as it seems to depend on order of finalizers during shutdown I can't seem to figure out a sequence that makes it trigger. I see it building my blog as a static site using the Pelican static site generator, and it's been reported as a bug against the Pelican sitemap plugin here: https://github.com/pelican-plugins/sitemap/issues/35
Running pelican under pdb I can see that the only weakrefs created are from
blinker
. The sitemap plugin connects up three signals, everything works as expected, and then three ignored exceptions are logged when exiting pdm (as this is when the Python interpreter exits):Click for pdm session log breaking on all new weakrefs and showing the errors
``` (Pdb) b weakref.py:46 Breakpoint 1 at /usr/lib/python3.12/weakref.py:46 (Pdb) b weakref.py:53 Breakpoint 2 at /usr/lib/python3.12/weakref.py:53 (Pdb) r > /usr/lib/python3.12/weakref.py(53)__new__() -> def _cb(arg): (Pdb) bt /usr/lib/python3.12/bdb.py(606)run() -> exec(cmd, globals, locals)Possible fix
Happy to submit the patch as a PR if that's helpful for you, but I'm not certain it's the right fix.
Thanks for your time, please let me know if I can provide any other information.
Python version: 3.12 Blinker version: 1.8.2