python - Multiple "finally" clauses/"with" statements added on the fly? -


let's writing code need fail-safe section - in case of failure - save me wasting money. example, code buys virtual servers via aws api , since paid per hour, it's preferable shut them down stop being useful.

the problem is, don't know how many such instances use , create them on fly, adding them list or whatnot. "destructor" of each of instance might have unexpected exception , because of that, i'm afraid code finally clause ugly. cannot think of how use with because introducing objects on fly. other fail-safe solutions use python?


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -