import json from background import celery @celery.task(name='test') def test_task(): with open('test.json', 'a') as tf: tf.write(json.dumps({'ok': True}))