Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Commit

Permalink
Catch an error on the dataset queue
Browse files Browse the repository at this point in the history
  • Loading branch information
vegitron committed Jul 7, 2015
1 parent 885a92d commit f5985f4
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions sqlshare_rest/util/dataset_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sqlshare_rest.util.queue_triggers import trigger_upload_queue_processing
from sqlshare_rest.util.queue_triggers import UPLOAD_QUEUE_PORT_NUMBER
from sqlshare_rest.logger import getLogger
from django.db.utils import DatabaseError
import atexit

import socket
Expand Down Expand Up @@ -144,16 +145,23 @@ def close_socket():
# We don't actually have a protocol to speak...
clientsocket.close()

uploads = FileUpload.objects.filter(dataset_created=False,
is_finalized=True,
has_error=False,
pk__gt=newest_pk)
for upload in uploads:
if upload.pk > newest_pk:
newest_pk = upload.pk
if verbose:
print("Adding upload ID %s to the queue." % upload.pk)
q.put(upload)
try:
uploads = FileUpload.objects.filter(dataset_created=False,
is_finalized=True,
has_error=False,
pk__gt=newest_pk)
for upload in uploads:
if upload.pk > newest_pk:
newest_pk = upload.pk
if verbose:
print("Adding upload ID %s to the queue." % upload.pk)
q.put(upload)
except DatabaseError as ex:
ex_str = str(ex)
# If there's just, say, a network glitch, carry on.
# If it's anything else, re-raise the error.
if str_ex.find("Read from the server failed") < 0:
raise

q.join()

Expand Down

0 comments on commit f5985f4

Please sign in to comment.