Functions run during setup using Robot.run() should each run in their own thread, and main should also run in a thread. This would match how Runtime works. However, this will be difficult to implement with our current WebWorker/Pyodide setup and will likely be a longer project.
We would likely need to spawn a worker for each Robot.run() call, then have each worker contain a wrapper Robot class whose functions trigger a postMessage() that changes the state of the root worker (which contains the master definition of the robot's current state). One challenge is figuring out how to pass the code to each worker, especially with regards to how the global student code variables (Robot, Gamepad, Keyboard) are stored.
Functions run during
setup
using Robot.run() should each run in their own thread, andmain
should also run in a thread. This would match how Runtime works. However, this will be difficult to implement with our current WebWorker/Pyodide setup and will likely be a longer project.We would likely need to spawn a worker for each Robot.run() call, then have each worker contain a wrapper Robot class whose functions trigger a postMessage() that changes the state of the root worker (which contains the master definition of the robot's current state). One challenge is figuring out how to pass the code to each worker, especially with regards to how the global student code variables (Robot, Gamepad, Keyboard) are stored.