dddp/websocket.py
def safe_call(func, *args, **kwargs):
    """
    Call `func(*args, **kwargs)` but NEVER raise an exception.

    Useful in situations such as inside exception handlers where calls to
    `logging.error` try to send email, but the SMTP server isn't always
    availalbe and you don't want your exception handler blowing up.
    """
    try:
        return None, func(*args, **kwargs)
    except Exception:  # pylint: disable=broad-except
        # something went wrong during the call, return a stack trace that can
        # be dealt with by the caller
        return traceback.format_exc(), None
def safe_call(func, *args, **kwargs):
    """
    Call `func(*args, **kwargs)` but NEVER raise an exception.

    Useful in situations such as inside exception handlers where calls to
    `logging.error` try to send email, but the SMTP server isn't always
    availalbe and you don't want your exception handler blowing up.
    """
    try:
        return None, func(*args, **kwargs)
    except Exception:  # pylint: disable=broad-except
        # something went wrong during the call, return a stack trace that can
        # be dealt with by the caller
        return traceback.format_exc(), None
Call `func(*args, **kwargs)` but NEVER raise an exception.

    Useful in situations such as inside exception handlers where calls to
    `logging.error` try to send email, but the SMTP server isn't always
    availalbe and you don't want your exception handler blowing up.