python - Scope of warnings.simplefilter('error', Image.DecompressionBombWarning) -
i have following skeleton tornado program:
class is(basehandler): @tornado.gen.coroutine def get(self): #render stuff def post(self): try: # load image except runtimewarning: # handle exception class application(tornado.web.application): def __init__(self): # current handlers handlers = [ (r'/',is), ] # settings dict application settings = { "template_path": "templates", "static_path": "static" } tornado.web.application.__init__(self,handlers,debug=true,**settings) if __name__ =='__main__': # right place set warnings? warnings.simplefilter('error', image.decompressionbombwarning) app=application() server=tornado.httpserver.httpserver(app) server.listen(7000) tornado.ioloop.ioloop.current().start()
i'm wondering scope of settings warnings is? have set within class? or have set ok? or should within application init?
warnings.simplefilter
affects whole process (when not called inside with warnings.catch_warnings()
block), control warnings globally have call once @ startup, you've done.
Comments
Post a Comment