Skip to content

Commit 5bacf10

Browse files
authored
suppress exceptions when closing handlers during __del__ (#912)
1 parent 1805ad9 commit 5bacf10

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

traitlets/config/application.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,11 @@ def exit(self, exit_status: int | str | None = 0) -> None:
10621062
sys.exit(exit_status)
10631063

10641064
def __del__(self) -> None:
1065-
self.close_handlers()
1065+
# __del__ may be called during process teardown,
1066+
# at which point any fraction of attributes and modules may have been cleared,
1067+
# e.g. even _accessing_ self.log may fail.
1068+
with suppress(Exception):
1069+
self.close_handlers()
10661070

10671071
@classmethod
10681072
def launch_instance(cls, argv: ArgvType = None, **kwargs: t.Any) -> None:

0 commit comments

Comments
 (0)