Skip to content

Commit

Permalink
feat: [AXM-589] Add retry to content generation task
Browse files Browse the repository at this point in the history
  • Loading branch information
KyryloKireiev committed Jun 11, 2024
1 parent 0d3c27b commit f40e793
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions openedx/features/offline_mode/assets_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def save_asset_file(temp_dir, xblock, path, filename):


def create_subdirectories_for_asset(file_path):
"""
Creates subdirectories for asset.
"""
out_dir_name = '/'
for dir_name in file_path.split('/')[:-1]:
out_dir_name = os.path.join(out_dir_name, dir_name)
Expand Down
3 changes: 3 additions & 0 deletions openedx/features/offline_mode/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@

DEFAULT_OFFLINE_SUPPORTED_XBLOCKS = ['html']
OFFLINE_SUPPORTED_XBLOCKS = getattr(settings, 'OFFLINE_SUPPORTED_XBLOCKS', DEFAULT_OFFLINE_SUPPORTED_XBLOCKS)

RETRY_BACKOFF_INITIAL_TIMEOUT = 60 # one minute
MAX_RETRY_ATTEMPTS = 5
8 changes: 6 additions & 2 deletions openedx/features/offline_mode/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from xmodule.modulestore.django import modulestore

from .constants import OFFLINE_SUPPORTED_XBLOCKS
from .constants import MAX_RETRY_ATTEMPTS, OFFLINE_SUPPORTED_XBLOCKS, RETRY_BACKOFF_INITIAL_TIMEOUT
from .renderer import XBlockRenderer
from .utils import generate_offline_content

Expand All @@ -25,7 +25,11 @@ def generate_offline_content_for_course(course_id):
generate_offline_content_for_block.apply_async([str(xblock.location), html_data])


@shared_task
@shared_task(
autoretry_for=(Exception,),
retry_backoff=RETRY_BACKOFF_INITIAL_TIMEOUT,
retry_kwargs={'max_retries': MAX_RETRY_ATTEMPTS}
)
@set_code_owner_attribute
def generate_offline_content_for_block(block_id, html_data):
"""
Expand Down

0 comments on commit f40e793

Please sign in to comment.