So this needs to run every roughly 10 seconds?
Consider getting rid of the loop altogether and instead making a systemd unit that calls the script at an interval. Something like:
Code:
[Unit]
Description=Read DHT sensor
[Service]
User=%I
Restart=always
RestartSec=10s
ExecStart=#!/usr/bin/python3 /path/to/your/script.py
Put that in /etc/systemd/system/read-dht-sensor.service and then do systemctl enable read-dht-sensor --now (I think).
I'm assuming this is on Raspbian and/or that you have systemd.