From cf8a4da9e78a08d41450f30861525c40d9ec780f Mon Sep 17 00:00:00 2001
From: Simone Margaritelli <evilsocket@gmail.com>
Date: Tue, 5 Nov 2019 14:33:16 +0100
Subject: [PATCH] misc: small fix or general refactoring i did not bother
 commenting

---
 pwnagotchi/ui/web/handler.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pwnagotchi/ui/web/handler.py b/pwnagotchi/ui/web/handler.py
index a04cc54..2b02130 100644
--- a/pwnagotchi/ui/web/handler.py
+++ b/pwnagotchi/ui/web/handler.py
@@ -1,5 +1,6 @@
 import logging
 import os
+import _thread
 
 # https://stackoverflow.com/questions/14888799/disable-console-messages-in-flask-server
 logging.getLogger('werkzeug').setLevel(logging.ERROR)
@@ -125,7 +126,7 @@ class Handler:
         try:
             return render_template_string(STATUS_PAGE, title=pwnagotchi.name(), message='Shutting down ...')
         finally:
-            pwnagotchi.shutdown()
+            _thread.start_new_thread(pwnagotchi.shutdown, ())
 
     # serve a message and restart the unit in the other mode
     def restart(self):
@@ -137,7 +138,7 @@ class Handler:
             return render_template_string(STATUS_PAGE, title=pwnagotchi.name(),
                                           message='Restart in %s mode ...' % mode)
         finally:
-            pwnagotchi.restart(mode)
+            _thread.start_new_thread(pwnagotchi.shutdown, (mode,))
 
     # serve the PNG file with the display image
     def ui(self):