def reap_threads(func):
 if (not thread):
  return func
 @functools.wraps(func)
 def decorator(*args):
  key = threading_setup()
  try:
   return func(*args)
  finally:
   threading_cleanup(*key)
 return decorator

def reap_threads ( func ) : if ( not thread ) : return func @ functools . wraps ( func ) def decorator ( * args ) : key = threading_setup ( ) try : return func ( * args ) finally : threading_cleanup ( * key ) return decorator
use this function when threads are being used .