Retrieve Object from SFC Instance

In the initial action on a SFC I have the following code in the 'onStart' function...

def onStart(chart, step):
	chart.queue = recipe.obj.queue.Queue()
	chart.loaded_program = None

While the chart is running, I can see the 'queue' object

In another script, I am trying to fetch the queue object, to manipulate it, like so, obviously passing in 'queue' as the param_key

def chart_vars(param_key):
	obj = None
	if sequence.control.is_chart_running():
		chart_id = utils.paths.get_tag(sequence.tag_paths.path_sfc_chart_id)
		chart_vars = system.sfc.getVariables(chart_id)
		obj = chart_vars[param_key]
	return obj

However, running the above function from the scripting console causes a major exception, which seems to actually crash the connection to the gateway for 5 - 10 seconds. But interestingly does not crash the SFC instance.

Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File "<module:sequence.get>", line 7, in chart_vars
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(

	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(

	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(

	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(

	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.moduleInvokeSafe(

	at com.inductiveautomation.ignition.client.gateway_interface.ModuleRPCFactory$DynamicRPCHandler.invoke(

	at com.sun.proxy.$Proxy47.getVariables(Unknown Source)

	at com.inductiveautomation.sfc.client.scripting.ClientScriptingFunctions.getVariables(

	at com.inductiveautomation.sfc.scripting.SfcScriptingFunctionsPyWrapper.getVariables(

	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)

com.inductiveautomation.ignition.client.gateway_interface.GatewayException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: ImportError: No module named queue

I get the feeling I am trying to do something that is bad practice and that's why this isn't working?

Is there a 'correct' way to do this, or is this a no no?

As always thank you!

This seems suspicious. Have you tried renaming things (the chart variable, your project library script) to see if you have the same issues? There's a first-party queue module in the standard library that seems like it might be affecting things.

I just tried your suggestion, same result.

I'm wondering if I need to put my custom python objects in the library, rather than inside of a gateway script?

After further investigation this problem seems to be related to where the object is located in the project library. If the script containing the object is at the top of the tree fetching the instance of from the SFC works. However, if the object is contained in a package the error occurs.

Oh. I'll bet this is just an unintended consequence of when we changed project resource storage in 8.0. You should contact support and they can help isolate the root of the issue here a bit and get a ticket filed.