Multiprocessing: how to run Blockly generated code in Python
summary
Blockly yields a Python code string for a GoPiGo3 Raspberry Pi robot; solutions explored are exec - quick for short commands, then subprocess - can be interrupted and finally multiprocessing - pass data back and forth by using queues. The shipped approach wraps the string into a generated function, writes it to a tmp RAM file, imports/reloads it, spawns it as a worker process with a Queue for status messages, tracks PIDs to terminate runaway loops and reaps zombies; the robot demo runs and the project moves to Python 3.
AI-written summary · about
