def mute(fn):
 @wraps(fn)
 def wrapper(self, *args, **kwargs):
  thread_output_stream.setdefault(threading.current_thread(), []).append(DummyFile())
  try:
   return fn(self, *args, **kwargs)
  finally:
   thread_output_stream[threading.current_thread()].pop()
 return wrapper

def mute ( fn ) : @ wraps ( fn ) def wrapper ( self , * args , ** kwargs ) : thread_output_stream . setdefault ( threading . current_thread ( ) , [ ] ) . append ( DummyFile ( ) ) try : return fn ( self , * args , ** kwargs ) finally : thread_output_stream [ threading . current_thread ( ) ] . pop ( ) return wrapper
decorate a function that prints to stdout .