views.py
def hoge(request):
with transaction.atomic():
tasks.huga.delay()
retrun response
- 上記コードのトランザクションの範囲は、celeryのジョブキューにタスクを積むという処理に対してかかるので意味がない。
- hoge関数の処理にトランザクションをかけたい場合は、タスクの処理内にトランザクションを記述する。
views.py
def hoge(request):
with transaction.atomic():
tasks.huga.delay()
retrun response