def with_worker_threads(n_threads, dbname='foo', n_jobs=sys.maxsize, timeout=10.0):
 def newth(ii):
  return threading.Thread(target=_worker_thread_fn, args=(('hostname', ii), n_jobs, timeout, dbname))
 def deco(f):
  def wrapper(*args, **kwargs):
   threads = list(map(newth, list(range(n_threads))))
   [th.start() for th in threads]
   try:
    return f(*args, **kwargs)
   finally:
    [th.join() for th in threads]
  wrapper.__name__ = f.__name__
  return wrapper
 return deco

def with_worker_threads ( n_threads , dbname = 'foo' , n_jobs = sys . maxsize , timeout = 10.0 ) : def newth ( ii ) : return threading . Thread ( target = _worker_thread_fn , args = ( ( 'hostname' , ii ) , n_jobs , timeout , dbname ) ) def deco ( f ) : def wrapper ( * args , ** kwargs ) : threads = list ( map ( newth , list ( range ( n_threads ) ) ) ) [ th . start ( ) for th in threads ] try : return f ( * args , ** kwargs ) finally : [ th . join ( ) for th in threads ] wrapper . __name__ = f . __name__ return wrapper return deco
decorator that will run a test with some mongoworker threads in flight .