1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

#2006: Prevent script/report execution if no RQ worker is running

This commit is contained in:
Jeremy Stretch
2020-07-13 15:11:58 -04:00
parent e53839ca2a
commit 05aa008ce1
3 changed files with 40 additions and 7 deletions

View File

@ -1,5 +1,19 @@
from rest_framework import status
from rest_framework.exceptions import APIException
class AbortTransaction(Exception):
"""
A dummy exception used to trigger a database transaction rollback.
"""
pass
class RQWorkerNotRunningException(APIException):
"""
Indicates the temporary inability to enqueue a new task (e.g. custom script execution) because no RQ worker
processes are currently running.
"""
status_code = status.HTTP_503_SERVICE_UNAVAILABLE
default_detail = 'Unable to process request: RQ worker process not running.'
default_code = 'rq_worker_not_running'