def terminate_threads(func):
 def wrapper(*args, **kwargs):
  cur_threads = set(threading.enumerate())
  try:
   return func(*args, **kwargs)
  finally:
   do_terminate_threads((set(threading.enumerate()) - cur_threads))
 wrapper.__name__ = func.__name__
 return wrapper

def terminate_threads ( func ) : def wrapper ( * args , ** kwargs ) : cur_threads = set ( threading . enumerate ( ) ) try : return func ( * args , ** kwargs ) finally : do_terminate_threads ( ( set ( threading . enumerate ( ) ) - cur_threads ) ) wrapper . __name__ = func . __name__ return wrapper
kills all worker threads the method has created by sending the quit signal .