Using context.run in MUSE Python Code
Question:
What does the context.run(globals()) command do in my Python code?
Answer:
The context.run(globals()) command should only be run at the end of a top-level script on your MUSE controller. The purpose of the command is to keep your script alive by creating a no-op loop keeping the Mojo enviornment avaiable for other processes. In addition, it allows for the globals() dictionary to be accessed while the script is running.
This isn't to say that all functions within a script will not work without the context.run(globals()) command. Callbacks, like watches and listens, will still be accessible in your script even without the command. Only the globals() dictionary access will fail to work, which means any variable declared as global would fail to work.
The commmand should only exist in the top-level script because including another script with that command will cause the no-op loop to start during the running of the top-level script causing unexpected issues in how your script will run.