Can't exit o.o;

Hey everyone. For some reason when I call my “clean up def” to exit the game, nothing happens while if I call for exit in the main code, it exits just fine.

    self.LogOut()

    def LogOut(self):
      try:
        try:
          self.client.close
        except:
          pass
        self.AllShutDown = False
        sys.exit()
      except:
        import traceback
        print traceback.format_exception(*sys.exc_info())

sys.exit() actually works by raising the exception SystemExit. Normally, when you raise SystemExit all the way to the top, it exits the program.

In your try…except handler, you have caught the SystemExit exception, and printed it out. If you want to allow it to exit normally instead, you could treat SystemExit as a special case, e.g.:

try:
  .. blah blah ..
except SystemExit:
  raise
except:
  .. blah blah ..

David

Yea, I tried removing the try except, but the call still ends up doing nothing once I call it.

So are you saying I need to move that section of code at the top? Or I’m a little lost on what you mean “raise SystemExit all the way to the top”

Nvm, it started working now. Thanks drwr. I hope it doesn’t break again…