Better exception handling, fixes

pull/66/head
Piero Toffanin 2016-12-13 09:52:15 -05:00
rodzic 9f674a1b41
commit bf9a7ba718
3 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -40,4 +40,4 @@ def boot():
scheduler.update_nodes_info(background=True)
except ProgrammingError:
logger.warn("Could not touch the database. If running a migration, this is expected.")
logger.warning("Could not touch the database. If running a migration, this is expected.")

Wyświetl plik

@ -189,8 +189,8 @@ class Task(models.Model):
try:
if self.processing_node:
# Need to process some images (UUID not yet set)?
if not self.uuid:
# Need to process some images (UUID not yet set and task not marked for deletion)?
if not self.uuid and self.pending_action != pending_actions.REMOVE:
logger.info("Processing... {}".format(self))
images = [image.path() for image in self.imageupload_set.all()]

Wyświetl plik

@ -1,5 +1,6 @@
from __future__ import unicode_literals
import requests
from django.db import models
from django.contrib.postgres import fields
from django.utils import timezone
@ -84,7 +85,11 @@ class ProcessingNode(models.Model):
if len(images) < 2: raise ProcessingException("Need at least 2 images")
api_client = self.api_client()
result = api_client.new_task(images, name, options)
try:
result = api_client.new_task(images, name, options)
except requests.exceptions.ConnectionError as e:
raise ProcessingException(e)
if result['uuid']:
return result['uuid']
elif result['error']: