Skip to content

Commit 0662cc1

Browse files
committed
Move move_files to a broadcast model.
This will require an update to the Settings in prod, to default a RemotePuller instead of the DoubleRemotePuller
1 parent a4cd571 commit 0662cc1

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

readthedocs/core/utils/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def run_on_app_servers(command):
4242
return ret
4343

4444

45-
def broadcast(type, task, args): # pylint: disable=redefined-builtin
45+
def broadcast(type, task, args, kwargs=None): # pylint: disable=redefined-builtin
4646
assert type in ['web', 'app', 'build']
4747
default_queue = getattr(settings, 'CELERY_DEFAULT_QUEUE', 'celery')
4848
if type in ['web', 'app']:
@@ -53,6 +53,7 @@ def broadcast(type, task, args): # pylint: disable=redefined-builtin
5353
task.apply_async(
5454
queue=server,
5555
args=args,
56+
kwargs=kwargs,
5657
)
5758

5859

readthedocs/projects/tasks.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,10 @@ def build_docs_html(self):
395395

396396
# Gracefully attempt to move files via task on web workers.
397397
try:
398-
move_files.delay(
399-
version_pk=self.version.pk,
400-
html=True,
401-
hostname=socket.gethostname(),
402-
)
398+
broadcast(type='app', task=move_files,
399+
args=[self.version.pk, socket.gethostname()],
400+
kwargs=dict(html=True)
401+
)
403402
except socket.error:
404403
# TODO do something here
405404
pass
@@ -559,15 +558,14 @@ def finish_build(version_pk, build_pk, hostname=None, html=False,
559558
if not epub:
560559
clear_epub_artifacts(version)
561560

562-
move_files(
563-
version_pk=version_pk,
564-
hostname=hostname,
565-
html=html,
566-
localmedia=localmedia,
567-
search=search,
568-
pdf=pdf,
569-
epub=epub,
570-
)
561+
broadcast(type='app', task=move_files, args=[version_pk, hostname],
562+
kwargs=dict(
563+
html=html,
564+
localmedia=localmedia,
565+
search=search,
566+
pdf=pdf,
567+
epub=epub,
568+
))
571569

572570
# Symlink project on every web
573571
broadcast(type='app', task=symlink_project, args=[version.project.pk])

0 commit comments

Comments
 (0)