@contextmanager
def set_trap(app):
 trap = Trap()
 prev_tls = _state._tls
 _state.set_default_app(trap)
 class NonTLS(object, ):
  current_app = trap
 _state._tls = NonTLS()
 (yield)
 _state._tls = prev_tls

@ contextmanager def set_trap ( app ) : trap = Trap ( ) prev_tls = _state . _tls _state . set_default_app ( trap ) class NonTLS ( object , ) : current_app = trap _state . _tls = NonTLS ( ) ( yield ) _state . _tls = prev_tls
contextmanager that installs the trap app .