Can sys.exit () be done to get out of the bottle frame

I was hoping to put 'sys.exit (1)' and catch it later, as this will work.

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

Is there any other solution for exiting these python microstructures for exiting internally handlers?

+5
source share
3 answers

If you don’t handle it, check if it really executes the sys.exist (1) statement because some other exception may occur that is not being processed, 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)
+1
source

In case this is still a problem for you, check out my answer here for a clean solution on stopping the bottle frame.

+1
source

From my limited experience, sys.exit()should work when the reboot is off. Otherwise, the rebooter will reload the code on sys.exit()and your application will resume. Of course, I may be mistaken why it sys.exit()does not work, but for me it worked when I disabled reboot.

0
source

All Articles