fix: avoid "[PYI-28040:ERROR]" log message when run via pyinstaller

This commit is contained in:
sebthom
2025-04-27 14:34:56 +02:00
parent 7b0774874e
commit 52e1682dba
3 changed files with 19 additions and 6 deletions

View File

@@ -1184,12 +1184,20 @@ def main(args:list[str]) -> None:
loggers.configure_console_logging()
signal.signal(signal.SIGINT, error_handlers.on_sigint) # capture CTRL+C
sys.excepthook = error_handlers.on_exception
# sys.excepthook = error_handlers.on_exception
# -> commented out because it causes PyInstaller to log "[PYI-28040:ERROR] Failed to execute script '__main__' due to unhandled exception!",
# despite the exceptions being properly processed by our custom error_handlers.on_exception callback.
# We now handle exceptions explicitly using a top-level try/except block.
atexit.register(loggers.flush_all_handlers)
bot = KleinanzeigenBot()
atexit.register(bot.close_browser_session)
nodriver.loop().run_until_complete(bot.run(args))
try:
bot = KleinanzeigenBot()
atexit.register(bot.close_browser_session)
nodriver.loop().run_until_complete(bot.run(args))
except Exception:
error_handlers.on_exception(*sys.exc_info())
if __name__ == "__main__":