diff mbox series

httpserver: add error handler that write to the logger

Message ID 20230131163022.3521258-1-ross.burton@arm.com
State Accepted, archived
Commit a4bcca3123685f410fc99e5cc23f2b8f39fd0a63
Headers show
Series httpserver: add error handler that write to the logger | expand

Commit Message

Ross Burton Jan. 31, 2023, 4:30 p.m. UTC
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/lib/oeqa/utils/httpserver.py | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/utils/httpserver.py b/meta/lib/oeqa/utils/httpserver.py
index 2aa172bf799..80752c13770 100644
--- a/meta/lib/oeqa/utils/httpserver.py
+++ b/meta/lib/oeqa/utils/httpserver.py
@@ -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