Commit e50d45db by Eric Fischer Committed by GitHub

Merge pull request #14598 from edx/efischer/quick

Cleaner grades exception handling
parents c8f7587f 715076a4
......@@ -33,7 +33,20 @@ from .transformer import GradesTransformer
log = getLogger(__name__)
KNOWN_RETRY_ERRORS = (DatabaseError, ValidationError) # Errors we expect occasionally, should be resolved on retry
class DatabaseNotReadyError(IOError):
"""
Subclass of IOError to indicate the database has not yet committed
the data we're trying to find.
"""
pass
KNOWN_RETRY_ERRORS = ( # Errors we expect occasionally, should be resolved on retry
DatabaseError,
ValidationError,
DatabaseNotReadyError
)
RECALCULATE_GRADE_DELAY = 2 # in seconds, to prevent excessive _has_db_updated failures. See TNL-6424.
......@@ -101,7 +114,7 @@ def _recalculate_subsection_grade(self, **kwargs):
has_database_updated = _has_db_updated_with_new_score(self, scored_block_usage_key, **kwargs)
if not has_database_updated:
raise _retry_recalculate_subsection_grade(self, **kwargs)
raise DatabaseNotReadyError
_update_subsection_grades(
course_key,
......@@ -109,8 +122,6 @@ def _recalculate_subsection_grade(self, **kwargs):
kwargs['only_if_higher'],
kwargs['user_id'],
)
except Retry:
raise
except Exception as exc: # pylint: disable=broad-except
if not isinstance(exc, KNOWN_RETRY_ERRORS):
log.info("tnl-6244 grades unexpected failure: {}. task id: {}. kwargs={}".format(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment