AttributeError: 'AsyncResult' object has no attribute 'head'
In my views.py file the error throwing at data = df.head(50) when i'm running and retrive the data as asynchronous background task.
Could anybody help me here?
task.py
@shared_task
def eda_flow_task(path, mode):
sleep(30)
try:
with adls_client.open(path, mode) as f:
df = pd.read_csv(f, low_memory=False)
return 'data load success'
except Exception as e:
response_dict.update({'error': str(e)})
view.py
def eda_flow(request):
path = '/data/satyajit/us_amz.csv'
mode = 'rb'
df = eda_flow_task.delay(path, mode)
data = df.head(50)
json_records = data.reset_index().to_json(orient ='records')
data = []
data = json.loads(json_records)
context = {'data': data}
return render(request, "home/tables-simple.html", context)