You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,3 +83,11 @@ To explore the course more freely:
83
83
At the beginning of the course only the shell is available to encourage quick exploration. After a few pages an editor is introduced to allow running full programs.
84
84
85
85
The course provides three debuggers to specially run code: snoop, PythonTutor, and birdseye. Each should only become available starting from a specific page which introduces that tool. No such page has been written yet for birdseye, so for now it's immediately available when the editor is introduced.
86
+
87
+
##System overview
88
+
89
+
The UI is written in React. It communicates with the web server using the`rpc` function, e.g.`rpc("run_code", {code, source}, onSuccess)`. This eventually reaches a method in the`API` class, e.g.`def run_code(self, code, source):`.
90
+
91
+
Running code specifically sends a request from the web server to the workers master server. This forwards the request to a process associated with that user's ID, starting a new process if necessary. Every user has their own process, which holds the state of the shell or the currently running program (which may be awaiting`input()`). The processes are isolated from each other and everything else, they can easily be terminated, and they have limitations on CPU time usage and file access.
92
+
93
+
After the code finishes running, it checks the`Page` and`Step` that the user is currently on, and calls the`Step.check` method. In most cases this is a`VerbatimStep` - the user is supposed to enter exactly the code in the text, using the AST to check for equality. Next most common is an`ExerciseStep` where a function has to pass tests and produce the same output as a given solution. The result of`Step.check` determines if the user succeeded and advances to the next step. It may also return a message to show the user, e.g. if they made a common mistake.