If I execute a Python 3 script inside my Raspberry Pi 3 and it uses time.sleep(wait), it only works interactively. If I background the process using &, the script doesn't seem to work at all and I don't see any output in my CSV file the script writes to. It stays at file size 0 forever.
I've tried this by running a script directly (read-sensor >/var/lib/envirophat/sensor.csv &) and the same inside a Docker container (I'm using HypriotOS).
How can I read the sensor faster than once per minute (using crontab) but not continuously without any kind of sleep?
Looks like the output buffering was in fact the issue. It was working but never outputting anything so I couldn't tell. Using python3 -u seems to do the trick. I updated my Docker image to reflect this.
Using Python 3 time.sleep in Raspberry Pi 3 hangs process