Skip to contentSkip to conversation

httpserver: add error handler that write to the logger

PATCH New Ross Burton 1 participant 1 message Jan 31, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 httpserver: add error handler that write to the logger

---
 meta/lib/oeqa/utils/httpserver.py | 6 ++++++
 1 file changed, 6 insertions(+)
meta/lib/oeqa/utils/httpserver.py +6 -0
index 2aa172bf799..80752c13770 100644
@@ -44,6 +44,12 @@ class HTTPService:
             self.port = self.server.server_port
         self.process = multiprocessing.Process(target=self.server.server_start, args=[self.root_dir, self.logger])
 
+        def handle_error(self, request, client_address):
+            import traceback
+            exception = traceback.format_exc()
+            self.logger.warn("Exception when handling %s: %s" % (request, exception))
+        self.server.handle_error = handle_error
+
         # The signal handler from testimage.bbclass can cause deadlocks here
         # if the HTTPServer is terminated before it can restore the standard 
         #signal behaviour
Signature · 1 line
2.34.1