Fix stop() not working and preserve a SystemExit

This commit is contained in:
Kovid Goyal 2015-05-27 09:16:02 +05:30
parent e61c0bc92b
commit 700e1996c8

View File

@ -334,11 +334,13 @@ class ServerLoop(object):
self.ready = True self.ready = True
self.log('calibre server listening on', ba) self.log('calibre server listening on', ba)
while True: while self.ready:
try: try:
self.tick() self.tick()
except (KeyboardInterrupt, SystemExit): except (KeyboardInterrupt, SystemExit) as e:
self.shutdown() self.shutdown()
if isinstance(e, SystemExit):
raise
break break
except: except:
self.log.exception('Error in ServerLoop.tick') self.log.exception('Error in ServerLoop.tick')