[Twisted-Python] question about twisted conch (SSH) and wxPython

Phil Mayers p.mayers at imperial.ac.uk
Mon Jul 18 03:29:33 EDT 2005

Astan Chee wrote:
> def getPassword(self):
>        global RETRIES
>        if RETRIES  == 0:
>            RETRIES = 1
>            return defer.succeed(PASSWORD)
>        else:                      sys.exit(0)
> But it keeps on giving this error:
Yes, that's what sys.exit does, raise a SystemExit exception.

If you actually want a non-zero exit status, you need to reactor.stop 
and save your exit status somewhere, e.g.


def thing():
     global exitstatus
     if fail:
         exitstatus = 1

# We'll only get here once reactor.stop is called

A trivial bit of thought can solve this more elegantly than a global (gak!)

More information about the Twisted-Python mailing list