Implement queue

This commit is contained in:
Kumi 2019-02-07 20:52:59 +00:00
parent 1d2cbf8135
commit 3824fdabc7

View file

@ -20,6 +20,7 @@ from .device import makewificonfig, heartbeathandler
from .tasks import mkfirmware from .tasks import mkfirmware
from distutils.dir_util import copy_tree from distutils.dir_util import copy_tree
from celery.exceptions import TimeoutError
import glob import glob
import sys import sys
@ -72,7 +73,10 @@ def update(request):
device = get_object_or_404(Device, secret=request.POST.get("secret", "")) device = get_object_or_404(Device, secret=request.POST.get("secret", ""))
if not mkfirmware(device, FWDIR): try:
if not mkfirmware.delay(device, FWDIR).get(timeout=300):
return HttpResponse(status=503)
except TimeoutError:
return HttpResponse(status=503) return HttpResponse(status=503)
sigUpdateDevice(device.serial, None, False) sigUpdateDevice(device.serial, None, False)