Example #1
0
 def testSerial(self):
     os.environ['WM_WORK_MANAGER'] = 'serial'
     work_manager = make_work_manager()
     assert isinstance(work_manager, SerialWorkManager)
     with work_manager:
         future = work_manager.submit(will_succeed)
         future.get_result()
Example #2
0
 def testZeroMQ(self):
     os.environ['WM_WORK_MANAGER'] = 'zmq'
     os.environ['WM_N_WORKERS'] = str(3)
     work_manager = make_work_manager()
     assert isinstance(work_manager, ZMQWorkManager)
     with work_manager:
         future = work_manager.submit(will_succeed)
         future.get_result()
         assert work_manager.n_workers == 3
Example #3
0
 def testProcesses(self):
     os.environ['WM_WORK_MANAGER'] = 'processes'
     os.environ['WM_N_WORKERS'] = str(3)
     work_manager = make_work_manager()
     assert isinstance(work_manager, ProcessWorkManager)
     assert work_manager.n_workers == 3
     with work_manager:
         future = work_manager.submit(will_succeed)
         future.get_result()
Example #4
0
 def testArgs(self):
     parser = argparse.ArgumentParser()
     add_wm_args(parser)
     args = '--work-manager=threads --n-workers=3'.split()
     args = parser.parse_args(args)
     process_wm_args(args)
     work_manager = make_work_manager()
     assert isinstance(work_manager, ThreadsWorkManager)
     assert work_manager.n_workers == 3
Example #5
0
 def testArgFallthrough(self):
     # this test specifies the work manager on the command line, and the worker count in the environment
     # this simply tests whether we look to the environment in the case of a missing command line argument
     os.environ['WM_N_WORKERS'] = str(3)
     parser = argparse.ArgumentParser()
     add_wm_args(parser)
     args = '--work-manager=threads'.split()
     args = parser.parse_args(args)
     process_wm_args(args)
     work_manager = make_work_manager()
     assert isinstance(work_manager, ThreadsWorkManager)
     assert work_manager.n_workers == 3
Example #6
0
    def testZeroMQ(self):
        os.environ['WM_WORK_MANAGER'] = 'zmq'
        os.environ['WM_N_WORKERS'] = str(3)
        work_manager = make_work_manager()
        assert isinstance(work_manager, ZMQWorkManager)
        with work_manager:
            # Need to send enough work to start sufficient workers
            for _ in range(2):
                future = work_manager.submit(will_succeed)
                future.get_result()

            assert work_manager.n_workers == 3