python - Correct way to gracefully exit code prematurely from any section -


i have bunch of threads, classes, methods, , loops. in each level have pass, check, , handle global variable causes section of code exit before completing it's task if user wants exit program early.

every time-dependent section literally wrapped in if not quit_now(): (or similar). cannot code-fu - there better way?


Comments