def is_retryable(txn, error):
    """Check if this transaction is one caused by database conflict.

    These transactions should not be caught in catch all exception expressions.



    :param txn:
    :param error:
    :return:
    """
    if txn is None:
        return False
    for dm in txn._resources:
        should_retry = getattr(dm, 'should_retry', None)
        if should_retry is not None and should_retry(error):
            return True
