Leapo / Rock64-R64.GPIO

Python GPIO library for the Rock64 SBC (RPi.GPIO clone)
GNU Lesser General Public License v3.0
60 stars 25 forks source link

Use a different startmethod for curses comaptibility #9

Open AiyionPrime opened 2 years ago

AiyionPrime commented 2 years ago

Currently this project uses the multitprocessing module and makes use of Process(), which are started using start().

https://github.com/Leapo/Rock64-R64.GPIO/blob/fbf988a6106ab3a5d333cb4012cf779eb74e142a/R64/_GPIO.py#L352-L353

This does invoke one of the three different startmethods of multiprocessing implicitely. https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

Apparently one of the forking kind. This leads to an incompatibility with curses, as screen properties are reset, when a (forked) child process exits. Which means, everytime a PWM stop()s, curses screen does all sorts of stuff.

This project would not invoke such unwanted side effects, if started processes where spawned instead of forked. In documentation a few lines below the above reference https://docs.python.org/3/library/multiprocessing.html#multiprocessing.set_start_method is documented.

@Leapo Would it be possible to use it instead of the implicit behavior?