Closed lexa closed 8 years ago
Question: Why does sys.exit()
throw an exception?
Also, just so you know, the try ... except
is to ensure the script won't shut off on temporary network disconnections.
Question: Why does sys.exit() throw an exception?
Because that it is how sys.exit() described in python documentation:
sys.exit([arg]) Exit from Python. This is implemented by raising the SystemExit exception, so cleanup actions specified by finally clauses of try statements are honored, and it is possible to intercept the exit attempt at an outer level.
Also, just so you know, the try ... except is to ensure the script won't shut off on temporary network disconnections.
Don't worry, i preserved try ... except, program won't fail due to temporary network problems. The only change is in handling exit code.
Actually i have a slightly better idea of fixing problem with sys.exit(). I can just move sys.exit() out of the loop.
The purpose of adding main() is to properly handle sys.exit().
sys.exit() throws an exception, which is get caught by try block and has no effect and program continues to work despite lack of necessary files.