From 4b33d0f395538f1445df2f69fe5dfccfa92d1ee2 Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 28 Nov 2024 13:35:09 +0100 Subject: [PATCH] call close_handlers before garbage collection avoids bug when this is called by `Application.__del__` --- repo2docker/__main__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/repo2docker/__main__.py b/repo2docker/__main__.py index a61ef918a..fb4e78460 100644 --- a/repo2docker/__main__.py +++ b/repo2docker/__main__.py @@ -482,6 +482,15 @@ def main(): if r2d.log_level == logging.DEBUG: r2d.log.exception(e) sys.exit(1) + finally: + # workaround bug in traitlets Application.__del__: + # https://github.com/ipython/traitlets/pull/912 + # make sure close_handlers is called before process teardown + try: + r2d.close_handlers() + except AttributeError: + # traitlets < 5.10 + pass if __name__ == "__main__":