def task_tester(request):
if request.method == 'POST':
cache.set('marco', 'ping', 100)
sample_task.delay('marco', 'polo', 10)
return http.HttpResponse(
'Now make a GET request to this URL\n',
status=201,
)
else:
if not cache.get('marco'):
return http.HttpResponseBadRequest(
'Make a POST request to this URL first\n'
)
for i in range(3):
value = cache.get('marco')
if value == 'polo':
return http.HttpResponse('It works!\n')
time.sleep(1)
return http.HttpResponseServerError(
'Tried 4 times (4 seconds) and no luck :(\n'
)
评论列表
文章目录