Help with Exception, org.python.core.PyException: SystemExit: 0

In our Validation system we have seen the below error a few times, though is seems to be intermittent, and I’d like to get some help deciphering this if possible.
This is being generated by a script on a button in an embedded view. The button script calls a project script library function the essentially triggers a micrometer to carry out measurement tasks. Though we get this error, it seems like the part measurement carries on as expected. The micrometer is setup as a TCP Driver Device and is one of four different micrometers. We have only seen this error for the #2 micrometer, but we have only recently put any of the others to use.
We are using v8.1.10 of Ignition.
Any information as to the meaning of the error content would be helpful as I am at a bit of a loss as to how to track down the root cause of this error.
Thanks.

com.inductiveautomation.ignition.common.script.JythonExecException: SystemExit: 0
at org.python.core.PySystemState.exit(PySystemState.java:1619)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:208)
at org.python.core.PyObject.__call__(PyObject.java:477)
at org.python.core.PyObject.__call__(PyObject.java:481)
at org.python.core.PyMethod.__call__(PyMethod.java:141)
at org.python.pycode._pyx15159.switchMicrometerProgram$8(:524)
at org.python.pycode._pyx15159.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:150)
at org.python.core.PyFunction.__call__(PyFunction.java:426)
at org.python.pycode._pyx15798.runAction$1(:22)
at org.python.pycode._pyx15798.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyFunction.function___call__(PyFunction.java:474)
at org.python.core.PyFunction.__call__(PyFunction.java:469)
at org.python.core.PyFunction.__call__(PyFunction.java:464)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:849)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:831)
at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runFunction(ProjectScriptLifecycle.java:689)
at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:1000)
at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:754)
at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:133)
at com.inductiveautomation.perspective.gateway.action.ScriptAction.runAction(ScriptAction.java:71)
at com.inductiveautomation.perspective.gateway.action.ActionDecorator.runAction(ActionDecorator.java:18)
at com.inductiveautomation.perspective.gateway.action.SecuredAction.runAction(SecuredAction.java:44)
at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.lambda$call$0(ActionCollection.java:263)
at com.inductiveautomation.perspective.gateway.api.LoggingContext.mdc(LoggingContext.java:54)
at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:252)
at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:221)
at com.inductiveautomation.perspective.gateway.threading.BlockingTaskQueue$TaskWrapper.run(BlockingTaskQueue.java:154)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.python.core.PyException: SystemExit: 0
... 41 common frames omitted

Looks to me like you’re calling exit() from a Perspective script action?

Looks like you hit the nail on the head!
I’m not terribly familiar with this code as another developer wrote it.
There is a try/except block in the switchMicrometerProgram() function. The last line of the except section contains the line:

sys.exit(0)

Looking at the Python doc for this function, it seems this “exits from Python” and raises the exception.
I’m not an application developer, just an old electrical engineer pretending to be a software guy!
It doesn’t seem like this is hurting anything, but, is this the proper way to raise an exception in a script in Ignition?

Usually when I see someone trying to exit() it’s because they’re being lazy about control flow or can’t figure out another way to return early from the function they’re writing.

There’s probably a better way.

Thanks Kevin,
I’ll look into a change for this when time allows.
For now, unless it starts causing issues, we’ll leave it as is and I’ll also talk with the my fellow developer to see if he wants to revisit it as well.
:+1:

If the function doesn’t return anything then you can simply replace it with return.

1 Like