Regenerating multiple GeoMipTerrain pieces?

I’ve got code in place that will gather a bunch of variables for multiple GeoMipTerrain pieces into a dictionary. The code then loops through the dictionary to create the terrain pieces, but I’m not sure how to setup the task to regenerate the terrain.

Here’s the relevant code pieces:

class ZoneObject:
    def __init__(self, zid):
        print "ZoneObject is loading"
        self.ZoneID = zid

        self.TerrainFocalPoint = Vec3(0, 0, 0)

        self.TerrainPieces = []
        for terrainPiece in self.TerrainPieces:
            terrainHeightfieldImage = PNMImage()
            terrain = GeoMipTerrain(terrainPiece["name"])
            terrainBaseTexture = loader.loadTexture(terrainPiece["baseTexture"])
            terrain.getRoot().setPos(self.TerrainFocalPoint + terrainPiece["relativePosition"])

    def GenerateTerrainLibrary(self):
        terrainChunk = {}
        terrainChunk["heightfield"] = "Terrain/Z1-1.png"
        terrainChunk["zScale"] = 50
        terrainChunk["baseTexture"] = "Textures/Environment/grass.png"
        terrainChunk["relativePosition"] = Vec3(-5, 0, -50)
        terrainChunk["name"] = "Terrain1"        

        terrainChunk = {}
        terrainChunk["heightfield"] = "Terrain/Z1-1.png"
        terrainChunk["zScale"] = 50
        terrainChunk["baseTexture"] = "Textures/Environment/grass.png"
        terrainChunk["relativePosition"] = Vec3(-500, 10, -50)
        terrainChunk["name"] = "Terrain2"        

Right now the code places two identical pieces of terrain beside each other, but the problem is that if I setup the loop that is shown in the manual it will only update one piece of terrain because of how the code is setup.

The manual says to use this code:

# Add a task to keep updating the terrain
def updateTask(task):
  return task.cont
taskMgr.add(updateTask, "update")

However if I do that, it will only update the last terrain that was generate in the loop above.

Do I need to add a task to every piece of terrain in the loop in my code for this? Or is there a way to have a single task running that will regenerate each terrain piece?

The reason I’m coding it like this is because I want to eventually pass a zoneID into the GenerateTerrainLibrary function, which will generate different terrain pieces based on the specific zoneID (hence the ZoneID variable in the class right at the start). Because of this is made sense to use a loop to go through each piece to generate each one.

EDIT: Let me reiterate the question since it appears I answered it myself. I know I could create a task for each terrain piece in my loop, but that seems horribly inefficient. What I want is to create a task that will update every terrain piece (so if I had 5 terrain pieces I would have 1 task running, not 5). Is that even possible? Or am I stuck with a task for each piece?

The per-task overhead is minimal. It takes about the same amount of time to run 5 tasks that each do 1 step, than to run 1 task that does 5 steps.