fix the fix that fixed the fix

This commit is contained in:
Arti Zirk 2016-10-15 11:52:54 +02:00
parent f26ff29eef
commit 5aaccabc93

16
main.py
View File

@ -119,16 +119,19 @@ html = """<!DOCTYPE html>
temps = deque(maxlen=10)
arduino = None
def stream(dev):
with serial.Serial(ser_dev, timeout=1) as s:
global arduino
arduino = s
while True:
temperature = dev.readline().decode().strip().split()[0]
temperature = s.readline().decode().strip().split()
if not temperature:
continue
print("temperature", temperature)
temps.append(temperature)
temps.append(temperature[0])
arduino = None
def application(env, start_response):
@ -203,11 +206,8 @@ if __name__ == "__main__":
print("{} is not a valid tty device".format(ser_dev))
exit(1)
with serial.Serial(ser_dev, timeout=1) as s:
arduino = s
import threading
t = threading.Thread(target=stream, args=[s])
t = threading.Thread(target=stream, args=[ser_dev])
# classifying as a daemon, so they will die when the main dies
t.daemon = True