[PR #7820] [MERGED] Fix #7803: Clear sys.modules cache when reloading scripts #13286

Closed
opened 2025-12-29 22:26:33 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/7820
Author: @kkthxbye-code
Created: 11/12/2021
Status: Merged
Merged: 11/12/2021
Merged by: @jeremystretch

Base: developHead: script-reload


📝 Commits (2)

  • ae6ed97 Clear sys.modules cache when reloading scripts
  • 9458521 Merge branch 'netbox-community:develop' into script-reload

📊 Changes

1 file changed (+5 additions, -0 deletions)

View changed files

📝 netbox/extras/scripts.py (+5 -0)

📄 Description

Fixes: #7803

The PR clears the sys.modules entry for the script classes we are trying to load, allowing modification and removal of class names without restarting the application server.

I tested all scenarios I could think of and calling scripts from both the web ui and the API. There might be a slight performance penalty, but it should be very minor.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/7820 **Author:** [@kkthxbye-code](https://github.com/kkthxbye-code) **Created:** 11/12/2021 **Status:** ✅ Merged **Merged:** 11/12/2021 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `script-reload` --- ### 📝 Commits (2) - [`ae6ed97`](https://github.com/netbox-community/netbox/commit/ae6ed97a80f55e87cd75dc0e942069758a1cd38d) Clear sys.modules cache when reloading scripts - [`9458521`](https://github.com/netbox-community/netbox/commit/9458521f3e98bef4b197059e197386a054a1e7e4) Merge branch 'netbox-community:develop' into script-reload ### 📊 Changes **1 file changed** (+5 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/scripts.py` (+5 -0) </details> ### 📄 Description ### Fixes: #7803 The PR clears the sys.modules entry for the script classes we are trying to load, allowing modification and removal of class names without restarting the application server. I tested all scenarios I could think of and calling scripts from both the web ui and the API. There might be a slight performance penalty, but it should be very minor. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:26:33 +01:00
adam closed this issue 2025-12-29 22:26:33 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13286