Allow customization of job timeout for scripts #4371

Closed
opened 2025-12-29 18:35:20 +01:00 by adam · 9 comments
Owner

Originally created by @DanSheps on GitHub (Dec 16, 2020).

Originally assigned to: @kkthxbye-code on GitHub.

Environment

  • Python version: 3.6.6
  • NetBox version: 2.10.1

Proposed Functionality

  • Add JOB_TIMEOUT to Script base class
  • Add job_timeout=Script.JOB_TIMEOUT to enqueue_job kwarg (per docs, this is popped out on job start)

Use Case

With the move towards background job processing, the time constraint on scripts is no longer as restrictive. I feel allowing customization of the job_timeout per-script would be beneficial (if a job times out, the job is still also listed as "Running", this should be handled separately as a bug)

Database Changes

None

External Dependencies

None

Originally created by @DanSheps on GitHub (Dec 16, 2020). Originally assigned to: @kkthxbye-code on GitHub. ### Environment * Python version: 3.6.6 * NetBox version: 2.10.1 ### Proposed Functionality * Add JOB_TIMEOUT to Script base class * Add job_timeout=Script.JOB_TIMEOUT to enqueue_job kwarg (per docs, this is popped out on job start) ### Use Case With the move towards background job processing, the time constraint on scripts is no longer as restrictive. I feel allowing customization of the job_timeout per-script would be beneficial (if a job times out, the job is still also listed as "Running", this should be handled separately as a bug) ### Database Changes None ### External Dependencies None
adam added the status: acceptedtype: feature labels 2025-12-29 18:35:20 +01:00
adam closed this issue 2025-12-29 18:35:20 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 17, 2020):

Add JOB_TIMEOUT to Script base class

Should this be a Meta attribute?

@jeremystretch commented on GitHub (Dec 17, 2020): > Add JOB_TIMEOUT to Script base class Should this be a `Meta` attribute?
Author
Owner

@DanSheps commented on GitHub (Dec 17, 2020):

I think making it a Meta attribute would be reasonable.

@DanSheps commented on GitHub (Dec 17, 2020): I think making it a Meta attribute would be reasonable.
Author
Owner

@stale[bot] commented on GitHub (Feb 2, 2021):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@stale[bot] commented on GitHub (Feb 2, 2021): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@DanSheps commented on GitHub (Feb 2, 2021):

I am going to take a crack at this sometime this month. Just been a busy month so far.

@DanSheps commented on GitHub (Feb 2, 2021): I am going to take a crack at this sometime this month. Just been a busy month so far.
Author
Owner

@DanSheps commented on GitHub (Feb 5, 2021):

This will likely need a re-implementation of the @job decorator, most of it can be superclassed but delay might need to be re-worked (at least a little).

Thoughts @jeremystretch?

@DanSheps commented on GitHub (Feb 5, 2021): This will likely need a re-implementation of the @job decorator, most of it can be superclassed but delay might need to be re-worked (at least a little). Thoughts @jeremystretch?
Author
Owner

@DanSheps commented on GitHub (Oct 28, 2021):

Going to work on this after 3.1 is released

@DanSheps commented on GitHub (Oct 28, 2021): Going to work on this after 3.1 is released
Author
Owner

@IdRatherStand commented on GitHub (Jan 18, 2022):

For anyone interested in extending the script timeout prior to this FR being implemented, you need to modify the job decorator in scripts.py to specify a timeout:

@job('default',timeout=XXX)

Currently this is found here:
4b81d86311/netbox/extras/scripts.py (L404)

I'm sure this isn't an approved method or supported by any means however it sorted our use case where we needed around 7 minutes execution time. I'm afraid I don't have the python / django knowledge to raise a PR for this to be implemented properly.

@IdRatherStand commented on GitHub (Jan 18, 2022): For anyone interested in extending the script timeout prior to this FR being implemented, you need to modify the job decorator in `scripts.py` to specify a timeout: `@job('default',timeout=XXX) ` Currently this is found here: https://github.com/netbox-community/netbox/blob/4b81d86311e80c055bd5a8b1ad55b2472ebc69e8/netbox/extras/scripts.py#L404 I'm sure this isn't an approved method or supported by any means however it sorted our use case where we needed around 7 minutes execution time. I'm afraid I don't have the python / django knowledge to raise a PR for this to be implemented properly.
Author
Owner

@seros1521 commented on GitHub (Feb 22, 2022):

Customizable timeout for reports would also be useful.

@seros1521 commented on GitHub (Feb 22, 2022): Customizable timeout for reports would also be useful.
Author
Owner

@kkthxbye-code commented on GitHub (Apr 4, 2022):

I took a stab at this, hope you weren't working on it actively @DanSheps. I didn't want to take ownership before I verified that I could get it working.

@kkthxbye-code commented on GitHub (Apr 4, 2022): I took a stab at this, hope you weren't working on it actively @DanSheps. I didn't want to take ownership before I verified that I could get it working.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4371