Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [AXM-589] Add retry to content generation task #2574

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading