ファイルに Celery タスクが登録されていtasks.py
ます。誰かが /run/pk に POST すると、指定されたパラメーターでタスクを実行します。このタスクは他のタスク (通常の Python 関数) も実行します。サブタスクが作業を終了するたびにページ (/run/pk で返される HttpResponse) を更新したいと考えています。
これが私の仕事です:
from celery.decorators import task
@task
def run(project, branch=None):
if branch is None:
branch = project.branch
print 'Creating the virtualenv'
create_virtualenv(project, branch)
print 'Virtualenv created' ##### Here I want to send a signal or something to update my page
runner = runner(project, branch)
print 'Using {0}'.format(runner)
try:
result, output = runner.run()
except Exception as e:
print 'Error: {0}'.format(e)
return False
print 'Finished'
run = Run(project=project, branch=branch,
output=output, **result._asdict())
run.save()
return True