Commit 715076a4 by Eric Fischer

Cleaner grades exception handling

parent c8f7587f
...@@ -33,7 +33,20 @@ from .transformer import GradesTransformer ...@@ -33,7 +33,20 @@ from .transformer import GradesTransformer
log = getLogger(__name__) 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. 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): ...@@ -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) has_database_updated = _has_db_updated_with_new_score(self, scored_block_usage_key, **kwargs)
if not has_database_updated: if not has_database_updated:
raise _retry_recalculate_subsection_grade(self, **kwargs) raise DatabaseNotReadyError
_update_subsection_grades( _update_subsection_grades(
course_key, course_key,
...@@ -109,8 +122,6 @@ def _recalculate_subsection_grade(self, **kwargs): ...@@ -109,8 +122,6 @@ def _recalculate_subsection_grade(self, **kwargs):
kwargs['only_if_higher'], kwargs['only_if_higher'],
kwargs['user_id'], kwargs['user_id'],
) )
except Retry:
raise
except Exception as exc: # pylint: disable=broad-except except Exception as exc: # pylint: disable=broad-except
if not isinstance(exc, KNOWN_RETRY_ERRORS): if not isinstance(exc, KNOWN_RETRY_ERRORS):
log.info("tnl-6244 grades unexpected failure: {}. task id: {}. kwargs={}".format( 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