def wrapper(self, *args, **kwargs):
     # XXX should also be able to do gevent.SYSTEM_ERROR = object
     # which is a global default to all hubs
     get_hub_class().SYSTEM_ERROR = object
     try:
         return method(self, *args, **kwargs)
     finally:
         get_hub_class().SYSTEM_ERROR = system_error
def wrap_error_fatal(method):
    from gevent._hub_local import get_hub_class
    system_error = get_hub_class().SYSTEM_ERROR

    @wraps(method)
    def wrapper(self, *args, **kwargs):
        # XXX should also be able to do gevent.SYSTEM_ERROR = object
        # which is a global default to all hubs
        get_hub_class().SYSTEM_ERROR = object
        try:
            return method(self, *args, **kwargs)
        finally:
            get_hub_class().SYSTEM_ERROR = system_error

    return wrapper