Open
Conversation
Creating the timer and process currently works. However, adding any global to runpy causes it to fail. For sys, that's because multiprocessing can't process a module object. But I'm not sure why adding 'input' causes the process to stop immediately.
Checks for infinite loops in a killable process the first time. Second time, intercepts output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This draft works, but is not ideal.
The goal is to throw an exception when student code is in an infinite loop.
This is triggered when the student's code has taken more than six seconds to run.
This is in the dialog checker, so it's not run for the bit Units.
The hard problem is creating a killable process that modifies local variables.
runpy.run_path(script_name, _globals, module)can modify local variables through its global argument.multiprocessing.Process()creates a killable process, but its pickling requirement makes modification difficult.My current solution runs the process once using multiprocessing.Process() to check if the code contains an infinite loop. If it does, we stop testing the student's code and throw an exception. If it does not, we run the code again using
runpy.run_pathand process their output as normal.