(pec, code, pid=None, mode="simple")
| 156 | |
| 157 | |
| 158 | def run_single_process(pec, code, pid=None, mode="simple"): |
| 159 | if mode == "stub": |
| 160 | # no isolation |
| 161 | process = StubProcess(init_code=pec, pid=pid) |
| 162 | raw_output, error = run_code(process.shell.run_code, code) |
| 163 | |
| 164 | elif mode == "simple": |
| 165 | # no advanced functionality |
| 166 | process = SimpleProcess(pid) |
| 167 | process.start() |
| 168 | _ = process.executeTask(TaskCaptureOutput(pec)) |
| 169 | raw_output, error = process.executeTask(TaskCaptureOutput(code)) |
| 170 | |
| 171 | elif mode == "full" and BACKEND_AVAILABLE: |
| 172 | # slow |
| 173 | process = WorkerProcess(pid) |
| 174 | process.start() |
| 175 | _ = process.executeTask( |
| 176 | TaskCaptureFullOutput((pec,), "<PEC>", None, silent=True) |
| 177 | ) |
| 178 | output, raw_output = process.executeTask( |
| 179 | TaskCaptureFullOutput((code,), "script.py", None, silent=True) |
| 180 | ) |
| 181 | raw_output = raw_output["output_stream"] |
| 182 | error = raw_output["error"] |
| 183 | |
| 184 | else: |
| 185 | raise ValueError("Invalid mode") |
| 186 | |
| 187 | return process, raw_output, error |
| 188 | |
| 189 | |
| 190 | def run_exercise(pec, sol_code, stu_code, sol_wd=None, stu_wd=None, **kwargs): |
no test coverage detected