def test_terminate_5(self): scripts = [pytest.helpers.get_py_script(i, 1000000) for i in range(10)] with LocalTask(scripts, processes=min(CPU_COUNT, 2)) as task: with pytest.raises(PyJobError): task.run() pytest.helpers.unlink(task.script[4:]) pytest.helpers.unlink(task.script[:4] + task.log)
def test_performance_4(self): scripts = [pytest.helpers.get_py_script(i, 10000) for i in range(64)] with LocalTask(scripts, processes=CPU_COUNT) as task: task.run() all_found = all(os.path.isfile(f) for f in task.log) pytest.helpers.unlink(task.script + task.log) assert all_found
def test_terminate_9(self): scripts = [pytest.helpers.get_py_script(i, 10000) for i in range(4)] task = LocalTask(scripts, processes=CPU_COUNT) task.run() with pytest.raises(PyJobTaskLockedError): task.run() task.wait() all_found = all(os.path.isfile(f) for f in task.log) pytest.helpers.unlink(task.script + task.log) assert all_found
def test_terminate_7(self): scripts = [pytest.helpers.get_py_script(i, 10000) for i in range(10000)] with LocalTask(scripts, processes=min(CPU_COUNT, 2)) as task: task.run() time.sleep(5) task.kill() all_scripts_found = all(os.path.isfile(path) for path in task.script) some_logs_found = any(os.path.isfile(log) for log in task.log) and not all( os.path.isfile(log) for log in task.log ) pytest.helpers.unlink(task.script + task.log) assert all_scripts_found and some_logs_found
def test_terminate_2(self): scripts = [pytest.helpers.get_py_script(i, 10000) for i in range(4)] task = LocalTask(scripts, processes=CPU_COUNT) task.run() task.close() all_found = all(os.path.isfile(f) for f in task.log) pytest.helpers.unlink(task.script + task.log) assert all_found
def innerf(): task = LocalTask(scripts, processes=min(CPU_COUNT, 2)) task.run() files.extend(task.script + task.log)