The following (section) of a script i’m working on will run fine (doesn’t hang) running as a client, but when running it in the designer, designer hangs indefinitely if the print statement commented bellow is not here. I’ve tried replacing it with sleep() and it still hangs. I’m not sure why it’s working with the print statement there but not when it is gone.
What i am doing is writing the time to a text box that is inside a template instance. If i write to the text property of a text box which is not inside a template, it does not hang. This was working fine at one point but i made some changes to the template (which i cannot seem to figure out what exactly did this) now it hangs.
for component in container.components:
componentName = tagName + '_' + alarmName
if(component.name == componentName):
for component in component.components:
if(component.name == 'SnoozeControls'):
for component in component.components:
if(component.name == 'SnoozeStatus'):
print('*') # If this print statement is not here, designer hangs
component.text = str(hrTime)
I was being a bit lazy there, i have made them unique, still having the same issue. I did just notice that it the script doesn’t hang if i stay in the script editor, as soon as i switch over to the vision window that is when it hangs.
for component in container.components:
componentName = tagName + '_' + alarmName
if(component.name == componentName):
for component1 in component.components:
if(component1.name == 'SnoozeControls'):
for component2 in component1.components:
if(component2.name == 'SnoozeStatus'):
print('*')
component2.text = str(hrTime)
I will fix that, but at this time that part of the script is not running. I just found that i run the script via a button it does not hang, only when run via client timer script.
You are also using system.tag.browse() in the foreground. Like any other script function that calls out to the gateway, it should be called in a background script, and UI interaction handled with .invokeLater(). See this topic:
I make an exception for button actionPerformed scripts (short ones), as an operator can expect some processing delay upon their command.