Transaction in Python node question


I’m trying to create a node that can change the linestyle of a filled region passed into it. I currently have a working script that takes ina graphic style and a filled region and changes the linestyle, this requires a transaction. It work’s properly when run in manual mode, but when put into automatic mode, the transaction runs over and over and over again, until I force close the whole project. Is this normal for a python node that contains a transaction in it? All transactions must be used in manual mode? Or is there something that is wrong with my code. Here it is:

import clr
from Autodesk.DesignScript.Geometry import *

Import RevitAPI

import Autodesk
from Autodesk.Revit.DB import *

Import DocumentManager and TransactionManager

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System import *

Import ToDSType(bool) extension method

import Revit
#The inputs to this node will be stored as a list in the IN variables.
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
#These are my inputs for the Node
gStyle = IN[0]
filledRegion = IN[1]

#Declared Variables
output = list()
count = 0
for i in filledRegion:
count = count + 1

#Check each filled region

for i in range(0, count):

#Assign your output to the OUT variable.
OUT = output


If needed, I can post the DYN and a sample Revit File. Any help would be awesome. Thanks.