def with_worker_threads(n_threads, dbname='foo',
        n_jobs=sys.maxint, 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):
            # --start some threads
            threads = map(newth, 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__ # -- nose requires test in name
        return wrapper
    return deco
Decorator that will run a test with some MongoWorker threads in flight
dataset/ETHPy150Open hyperopt/hyperopt/hyperopt/tests/test_mongoexp.py/with_worker_threads