We have a function that we use for handling errors with our code. The intent is that an email is generated if we encounter an unexpected issue, and the email is sent both to the original developer and as well as to a group email inbox (Ignition) so that we can monitor issues with code across all locations and developers.
Occasionally we will have a very fast repeating error that will generate many emails in a very short period of time. When this happens, the group email inbox address is often added multiple times to the email even though we are confident that this is not in the code. Here is an example where the group email address (Ignition) is added multiple times to an email:
If there is a delay between the errors, this problem seems to go away and the emails only include one instance of the Ignition email address. Does Ignition, Java, or Jython somehow retain the email variable from the exception function and reuse it when that function is run again?
Here is a simplified version of our code. In the example below, we would see this error if we ran the code() function over again over again in a very short period of time. The send_email function at the end of the exception function is where we actually send the email.
GLOBAL_VARIABL = 'email@address.com'
def exception(email):
if type(email) is list:
# Add the group email distribution list to the variable
to.append('group_email@address.com')
elif type(email) is str:
# A single email address (string) was supplied to the function; convert 'to' to a list and add the group email distribution list to the variable
to = [email,'group_email@address.com']
# Send the email
send_email('exception error', to)
def code():
try:
print(a)
except:
exception(GLOBAL_VARIABL)