From a6c2aa2489cab40bf48baf4348837ffb00adf048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crist=C3=B3bal=20Ganter?= Date: Thu, 2 Jun 2016 14:43:33 -0400 Subject: [PATCH] Fixed GPIO not being cleaned after its use. --- server.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index 07a9707..9838ec5 100644 --- a/server.py +++ b/server.py @@ -1,15 +1,16 @@ from tornado.web import RequestHandler, Application from tornado.ioloop import IOLoop -#GPIO Setup import RPi.GPIO as GPIO -GPIO.setmode(GPIO.BOARD) -#Setup pin 3 as GPIO out to control relay module -GPIO.setup(3,GPIO.OUT) #define main loop def main(): try: + #GPIO Setup + GPIO.setmode(GPIO.BOARD) + #Setup pin 3 as GPIO out to control relay module + GPIO.setup(3, GPIO.OUT) + #Defining routes that can be accessed and their handlers rutas = [('/', ListHandler),('/onoff',OnOff)] app = Application(rutas, debug=False) @@ -21,6 +22,9 @@ def main(): except KeyboardInterrupt: exit() + finally: + GPIO.cleanup() + class ListHandler(RequestHandler): def get(self): #Renders the luz.html file