I am stuck in this problem for a whole day and the irrationality of this problem is wretching.
# urls.py
path('check_progress/<str:task_id>/', views_data.check_progress, name='check_progress'),
#views.py
def check_progress(request, task_id):
logger.info(f"Entered check_progress with task_id: {task_id}")
try:
task = AsyncResult(task_id)
data = {'state': task.state, 'percent': 0}
if task.state == 'PROGRESS':
task_info = task.info or {} # from self.update_state(state='PROGRESS', meta=TASK_INFO)
data['percent'] = task_info.get('percent', 0)
elif task.state == 'SUCCESS':
data['percent'] = 100
return JsonResponse(data)
except Exception as e:
logger.error(f"check_progress() failed. {e}")
When DEBUG = True
2024-01-24 01:24:42 [2024-01-23 17:24:42 +0000] [7] [DEBUG] GET /check_progress/abcg/
2024-01-24 01:24:42 2024-01-23 17:24:42,116:INFO - Entered check_progress with task_id: abcg
When DEBUG = False
[DEBUG] GET /check_progress/
2024-01-24 01:25:23 Internal Server Error: /check_progress/
2024-01-24 01:25:23 2024-01-23 17:25:23,980:ERROR - Internal Server Error: /check_progress/
2024-01-24 01:25:30 [2024-01-23 17:25:30 +0000] [7] [DEBUG] GET /check_progress/erergg
2024-01-24 01:25:30 Internal Server Error: /check_progress/erergg
2024-01-24 01:25:30 2024-01-23 17:25:30,964:ERROR - Internal Server Error: /check_progress/erergg
The debug settings is the only cause of problem. The weird thing is that this is the only endpoint with issue. Other endpoints dont have the same problem.
I cant even execute the first line of the view function. The view itself is broken.