From eb939cac2cad4939bc75dbaad0a39c2b3b499c49 Mon Sep 17 00:00:00 2001 From: Cameron Patrick Date: Sun, 1 Aug 2004 06:01:45 +0000 Subject: [PATCH] put in a generic exception handler --- sql-edition/servers/VendServer.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index 198b109..4e0b16c 100755 --- a/sql-edition/servers/VendServer.py +++ b/sql-edition/servers/VendServer.py @@ -423,9 +423,7 @@ class VendConfigFile: print "Error reading config file "+config_file+": " + str(e) sys.exit(1) - -if __name__ == '__main__': - +def do_vend_server(): options = parse_args() config_opts = VendConfigFile(options.config_file, config_options) @@ -446,3 +444,25 @@ if __name__ == '__main__': print print "Connection died, trying again..." + +if __name__ == '__main__': + while True: + try: + do_vend_server() + except KeyboardInterrupt: + print "Killed by SIGINT." + break + except: + (exc_type, exc_value, exc_traceback) = sys.exc_info() + print + print "Uh-oh, unhandled " + str(exc_type) + " exception" + print "Message: ", str(exc_value) + print + print_tb(exc_traceback) + del exc_traceback + print + print "This message should be considered a bug in the Vend Server." + print "Please report this to someone who can fix it." + print + print "Trying again anyway (might not help, but hey...)" + -- 2.20.1