Tag change doesnt always work

Hi, i have this script, tested in both gateway and client parts.
The script doesnt seem to trigger every time the flag is set.

And when it does react to the flag, it doesnt always log the info, it just sets the flag to 0 in the end (and it does the try part, and not the except)

So no errors occurs what i can see in the log.


EDIT: Also… sometimes it triggers the script twice and do 2 logging to the SQL server with the same info…
ignition script_20140930.txt (4.68 KB)