Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can sys.exit() be made to exit bottle framework

Tags:

python

bottle

I was hoping that putting 'sys.exit(1)' and catching it later like this will work.

xml_open()
try:
  run(reloader=True, host='localhost', port=8080)
except SystemExit:
  xml_save()
  print "Exited ..."

Is there any other solution to exit these python micro-frameworks to exit from inside the handlers ?

like image 539
vrdhn Avatar asked Nov 06 '22 09:11

vrdhn


1 Answers

If its not being handled then check whether Its really executes sys.exist(1) statement, because It may happen some other exception raised which is not being handled try this....

xml_open()
try:
  run(reloader=True, host='localhost', port=8080)
except SystemExit:
  xml_save()
  print "Exited ..."
except Exception, e:
  print "ohhh no.......",str(e)
  import pdb
  pdb.post_mortem()
  sys.exit(-1)
like image 127
shahjapan Avatar answered Nov 11 '22 04:11

shahjapan