def test_exception_in_all_worker_process(self):
     """ Tests that when all worker processes have exited, zmq will properly throw an exception
      when trying to ventilate instead of blocking indefinitely"""
     pool = ProcessPool(5)
     pool.start(ExceptionGeneratingWorker_5)
     with self.assertRaises(RuntimeError):
         for _ in range(10000):
             pool.ventilate("Datanum")
             time.sleep(.1)
    def test_all_workers_are_active_processes(self):
        """Check that the work is distributed among all workers"""
        WORKERS_COUNT = 10

        # Testing only ProcessPool since only it has the mechanism that waits for all workers to come online before
        # start finishes
        pool = ProcessPool(WORKERS_COUNT)

        pool.start(WorkerIdGeneratingWorker)
        for _ in range(100):
            pool.ventilate()

        active_worker_ids = [pool.get_results() for _ in range(100)]
        self.assertEqual(set(range(WORKERS_COUNT)), set(active_worker_ids))

        pool.stop()
        pool.join()