]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Patch gevent.Hub.handle_error 1057/head
authorZack Cerza <zack@redhat.com>
Fri, 24 Mar 2017 18:33:36 +0000 (12:33 -0600)
committerZack Cerza <zack@redhat.com>
Thu, 30 Mar 2017 18:31:56 +0000 (12:31 -0600)
So we don't miss out on any fun exceptions!

Lifted from:
https://github.com/ceph/calamari/commit/7edc4cfc7159175a552222700810dc943a0ca8ce

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/__init__.py

index d037f53a18f4e1b738f8de17c7f9aa9f13fcfa49..ffafee9af230ccda2e8288506232de9b1d214c90 100644 (file)
@@ -19,6 +19,7 @@ monkey.patch_all(
     subprocess=False,
 )
 import sys
+from gevent.hub import Hub
 
 # Don't write pyc files
 sys.dont_write_bytecode = True
@@ -93,3 +94,17 @@ def install_except_hook():
                                                          exc_traceback))
         sys.__excepthook__(exc_type, exc_value, exc_traceback)
     sys.excepthook = log_exception
+
+
+def patch_gevent_hub_error_handler():
+    Hub._origin_handle_error = Hub.handle_error
+
+    def custom_handle_error(self, context, type, value, tb):
+        if not issubclass(type, Hub.SYSTEM_ERROR + Hub.NOT_ERROR):
+            log.error("Uncaught exception (Hub)", exc_info=(type, value, tb))
+
+        self._origin_handle_error(context, type, value, tb)
+
+    Hub.handle_error = custom_handle_error
+
+patch_gevent_hub_error_handler()