add a callback for when an exception goes uncaught in any greenlet

    :param handler:
        the callback function. must be a function taking 3 arguments:

        - ``klass`` the exception class
        - ``exc`` the exception instance
        - ``tb`` the traceback object
    :type handler: function

    Note also that the callback is only held by a weakref, so if all other refs
    to the function are lost it will stop handling greenlets' exceptions

def global_exception_handler(handler):
    """add a callback for when an exception goes uncaught in any greenlet

    :param handler:
        the callback function. must be a function taking 3 arguments:

        - ``klass`` the exception class
        - ``exc`` the exception instance
        - ``tb`` the traceback object
    :type handler: function

    Note also that the callback is only held by a weakref, so if all other refs
    to the function are lost it will stop handling greenlets' exceptions
    """
    if not hasattr(handler, "__call__"):
        raise TypeError("exception handlers must be callable")
    log.info("setting a new global exception handler")

    state.global_exception_handlers.append(weakref.ref(handler))

    return handler