mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-09 00:58:16 -06:00
Default Logic if Queue does not exist
This commit is contained in:
parent
b203c9d916
commit
8409c97e1a
@ -110,11 +110,7 @@ By default, a script can be scheduled for execution at a later time. Setting `sc
|
|||||||
|
|
||||||
### `rq_queue_name`
|
### `rq_queue_name`
|
||||||
|
|
||||||
This will override the standard `QUEUE_MAPPINGS` setting for the be process by the worker. If a worker is not set to monitor any custom mapping the job will never run.
|
This will override the standard `QUEUE_MAPPINGS` setting for the be process by the worker. If the queue is not found then the default logic found in the settings file will be used.
|
||||||
|
|
||||||
### `rq_queue_name`
|
|
||||||
|
|
||||||
This will override the standard `QUEUE_MAPPINGS` setting for scripts the be process by the worker. If a worker is not set to monitor any custom mapping the job will never run.
|
|
||||||
|
|
||||||
### `job_timeout`
|
### `job_timeout`
|
||||||
|
|
||||||
|
@ -213,12 +213,21 @@ class Job(models.Model):
|
|||||||
name: Name for the job (optional)
|
name: Name for the job (optional)
|
||||||
user: The user responsible for running the job
|
user: The user responsible for running the job
|
||||||
schedule_at: Schedule the job to be executed at the passed date and time
|
schedule_at: Schedule the job to be executed at the passed date and time
|
||||||
|
rq_queue_name: Queue name to route the job to for processing
|
||||||
interval: Recurrence interval (in minutes)
|
interval: Recurrence interval (in minutes)
|
||||||
"""
|
"""
|
||||||
object_type = ObjectType.objects.get_for_model(instance, for_concrete_model=False)
|
object_type = ObjectType.objects.get_for_model(instance, for_concrete_model=False)
|
||||||
if rq_queue_name is None:
|
if rq_queue_name is None:
|
||||||
rq_queue_name = get_queue_for_model(object_type.model)
|
rq_queue_name = get_queue_for_model(object_type.model)
|
||||||
queue = django_rq.get_queue(rq_queue_name)
|
queue = django_rq.get_queue(rq_queue_name)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
queue = django_rq.get_queue(rq_queue_name)
|
||||||
|
except KeyError:
|
||||||
|
# User defined queue does not exist - return to default logic
|
||||||
|
rq_queue_name = get_queue_for_model(object_type.model)
|
||||||
|
queue = django_rq.get_queue(rq_queue_name)
|
||||||
|
|
||||||
status = JobStatusChoices.STATUS_SCHEDULED if schedule_at else JobStatusChoices.STATUS_PENDING
|
status = JobStatusChoices.STATUS_SCHEDULED if schedule_at else JobStatusChoices.STATUS_PENDING
|
||||||
job = Job.objects.create(
|
job = Job.objects.create(
|
||||||
object_type=object_type,
|
object_type=object_type,
|
||||||
|
Loading…
Reference in New Issue
Block a user