(code_str, output_queue)
| 290 | import matplotlib.pyplot as plt |
| 291 | |
| 292 | def worker_run_code(code_str, output_queue): |
| 293 | output_capture = io.StringIO() |
| 294 | sys.stdout = output_capture |
| 295 | try: |
| 296 | # Create a globals dictionary with __name__ set to "__main__" |
| 297 | globals_dict = {"__name__": "__main__"} |
| 298 | exec(code_str, globals_dict) |
| 299 | except Exception as e: |
| 300 | output_capture.write(f"[CODE EXECUTION ERROR]: {str(e)}\n") |
| 301 | traceback.print_exc(file=output_capture) |
| 302 | finally: |
| 303 | sys.stdout = sys.__stdout__ |
| 304 | output_queue.put(output_capture.getvalue()) |
| 305 | |
| 306 | def execute_code(code_str, timeout=600, MAX_LEN=1000): |
| 307 | #code_str = code_str.replace("\\n", "\n") |
nothing calls this directly
no outgoing calls
no test coverage detected