In a production environment, restarting the server or gateway is not a viable option. How can we prevent or work around this issue without requiring a restart?
The script console runs in designer scope. The designer has access to both saved and unsaved resources.
This is likely the root cause of the issues you are seeing. Never import project library scripts. Only reference them by fully qualified names.
For instance this:
from OEE_NEW import my_script
my_script()
Should just be:
OEE_NEW.my_script()
NOTE: Folder names are also required in the path.
Assuming you haven't imported the Libraries anywhere, and you haven't leaked them anywhere by using them unsafely, then saving the project will cause the scripting engine to restart, which will reload the scripts.
Saving an inheritable project will cascade down, causing any projects which inherit from it, to also restart their scripting engines. This can cause missed events and other things where scripts can not run because the scripting engine is unavailable, so caution should, as always, be taken to avoid those types of issues in a production environment.
It should not be nessesary to restart the gateway. I on 8.1 since 8.1.5 and I have never had to restart my gateway in order to get changes in my project libraries to take effect, a project save is the only thing that has ever been requiered.
For Tag Events, it depends on which type you are asking about. For valueChange Tag Events (those that are on the tags themselves), the script must be located in the project which is set as the Gateway Scripting Project. For Gateway Tag Change events, then the scripts must be available to the project in which they are configured.
The same goes for Timer Events, the scripts must be available to the project in which they are configured.
"Other Gateway-executed scripts" is really too vauge to give a good answer to.