mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Merge pull request #1387 from paperless-ngx/bugfix-task-error-prevents-consume
Bugfix: Catch all exceptions during the task signals
This commit is contained in:
commit
3af4808864
@ -11,7 +11,6 @@ from django.contrib.contenttypes.models import ContentType
|
|||||||
from django.db import DatabaseError
|
from django.db import DatabaseError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.db.utils import OperationalError
|
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils import termcolors
|
from django.utils import termcolors
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@ -514,7 +513,9 @@ def init_paperless_task(sender, task, **kwargs):
|
|||||||
paperless_task.name = task["name"]
|
paperless_task.name = task["name"]
|
||||||
paperless_task.created = task["started"]
|
paperless_task.created = task["started"]
|
||||||
paperless_task.save()
|
paperless_task.save()
|
||||||
except OperationalError as e:
|
except Exception as e:
|
||||||
|
# Don't let an exception in the signal handlers prevent
|
||||||
|
# a document from being consumed.
|
||||||
logger.error(f"Creating PaperlessTask failed: {e}")
|
logger.error(f"Creating PaperlessTask failed: {e}")
|
||||||
|
|
||||||
|
|
||||||
@ -527,10 +528,10 @@ def paperless_task_started(sender, task, **kwargs):
|
|||||||
)
|
)
|
||||||
paperless_task.started = timezone.now()
|
paperless_task.started = timezone.now()
|
||||||
paperless_task.save()
|
paperless_task.save()
|
||||||
except OperationalError as e:
|
|
||||||
logger.error(f"Creating PaperlessTask failed: {e}")
|
|
||||||
except PaperlessTask.DoesNotExist:
|
except PaperlessTask.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Creating PaperlessTask failed: {e}")
|
||||||
|
|
||||||
|
|
||||||
@receiver(models.signals.post_save, sender=django_q.models.Task)
|
@receiver(models.signals.post_save, sender=django_q.models.Task)
|
||||||
@ -542,7 +543,7 @@ def update_paperless_task(sender, instance, **kwargs):
|
|||||||
)
|
)
|
||||||
paperless_task.attempted_task = instance
|
paperless_task.attempted_task = instance
|
||||||
paperless_task.save()
|
paperless_task.save()
|
||||||
except OperationalError as e:
|
|
||||||
logger.error(f"Creating PaperlessTask failed: {e}")
|
|
||||||
except PaperlessTask.DoesNotExist:
|
except PaperlessTask.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Creating PaperlessTask failed: {e}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user