From f0b66bdfcb6c7689d306a8905490d69ef3c641c2 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Wed, 13 Aug 2014 01:15:24 +0200 Subject: [PATCH] main: Ensure that exit_status_code always is assigned KeyboardInterrupts are not always catched in commands.py. As far as I have seen, if I/O operations are ongoing, a KeyboardInterrupt may be raised there instead of in commands.py. In some cases, this may cause loop.run() to return, which previously resulted in exit_status_code being referenced before assignment. --- mopidy/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mopidy/commands.py b/mopidy/commands.py index db012208..2a0b6f48 100644 --- a/mopidy/commands.py +++ b/mopidy/commands.py @@ -265,6 +265,7 @@ class RootCommand(Command): backend_classes = args.registry['backend'] frontend_classes = args.registry['frontend'] + exit_status_code = 0 try: mixer = self.start_mixer(config, mixer_class) audio = self.start_audio(config, mixer) @@ -279,7 +280,6 @@ class RootCommand(Command): exit_status_code = 1 except KeyboardInterrupt: logger.info('Interrupted. Exiting...') - exit_status_code = 0 finally: loop.quit() self.stop_frontends(frontend_classes)