def set_greenlet_uncaught_exception_handler(func):
    """
    Sets a global greenlet uncaught exception handler that will get called if a greenlet spawned by one of this module's
    wrappers raises an uncaught exception.
    :param func: exception handler function that will receive the exc_info tuple as an argument
    :returns: previous exception handler function or None
    """
    global _uncaught_exception_handler
    prev_handler, _uncaught_exception_handler = (
        _uncaught_exception_handler, func)
    return prev_handler
