I recently came into contact with a 3D printer project. There are two codes, one is open source Python printrun, and the other is closed source C. Both of them use multi-threading. Among them, C uses the open source mlib to implement, which I can understand.
As far as the C code is concerned, each controller controls position, temperature, nozzle, etc., corresponding to a thread. The bottom layer is implemented through the same USB/serial port/CAN bus.
I am still checking whether printrun uses multi-threading to implement multiple controller threads like C code, or is it just multi-threading between the GUI and the serial port. Don’t designers worry about Python’s GIL affecting thread performance?
In addition, I have two options:
Port the C code to a driver based on RTOS, or RT-Linux and other similar platforms.
Change Python to multi-process, and each serial port uses asynio's asynchronous method to handle events.
I hope students who have had such experience can share their experience.
No need to worry about GIL for io-intensive applications