Scripts are running twice. I don't get it.

I just can’t figure this one out. I’m working on a simple follow-to-target routine. I have two python scripts, tracktonearest.py (initiates TrackTo target and imparts linear velocity) and stopchasing.py (stops it on contact with target)

tracktonearest.py is initiated by a sensor that detects when the property Hungry = 1:

print "Starting Tracking Program"
import GameLogic as g
cont = g.getCurrentController()
own = cont.getOwner()
print "On first initializing, Hungry = " + str(own.Hungry)
chase = cont.getActuator("chase")
track = cont.getActuator("trak")

object_list = g.getCurrentScene().getObjectList()
relevant_pairs = []

for object in object_list:
    if type(object) == type(own):
        distance = own.getDistanceTo(object)
        if hasattr(object,"Herbivore") and distance < 50:
            relevant_pairs.append((distance, object))
            own.Chasing = 1

relevant_pairs.sort()

if own.Chasing != 0:
    print "Chasing = " + str(own.Chasing) 
    own.CurrentPrey = relevant_pairs[0][1].name
    track.setObject(relevant_pairs[0][1])
    g.addActiveActuator(track,1)
    chase.setLinearVelocity(0, 1, 0, 1)
    g.addActiveActuator(chase,1)

stopchasing.py detects contact with the target object and is supposed to shut down the TrackTo actuators, (which require the pursuing object’s Chasing property to be True).

import GameLogic as g

print "Starting stopchasing.py"

cont = g.getCurrentController()
stoptrack = cont.getActuator("trak")
stop = cont.getActuator("chase")
colval = cont.getSensor("TouchingHerbivore")
print "colval.isPositive() = " + str(colval.isPositive())
own = cont.getOwner()
colobj = colval.getHitObject().name

if colval.isPositive():
    if colobj == own.CurrentPrey:
        stoptrack.setObject("")
        g.addActiveActuator(stoptrack, 1)
        stop.setLinearVelocity(0, 0, 0, 1)
        g.addActiveActuator(stop, 1)
        own.Hungry = 0
        print "Hungry = " + str(own.Hungry)
        own.Chasing = 0
        print "Chasing = " + str(own.Chasing)
        own.CaughtPrey = 1
        print "CaughtPrey = " + str(own.CaughtPrey)
        print "Hungry = " + str(own.Hungry)

The only notable property of the target is Herbivore.

Properties of the pursuer object are:
Hungry (int) - value of 1 activates tracktonearest.py
Chasing (int) - Set to 1 when tracktonearest.py finds a target, set to 0 when it contacts target
strName (string) – so far just used for debugging
TouchingHerbivore1 (bool) - whether or not touching Herbivore property
CurrentPrey (string) - name of object currently being pursued
CaughtPrey (bool) - whether or not target has been touched, which should activate stopchasing.py (for debugging)

Now the problem is twofold. First, it doesn’t seem to like the results of cont.getSensor(“TouchingHerbivore”), and gives me this:

PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “stopchasing.py”, line 12, in <module>

AttributeError: ‘NoneType’ object has no attribute ‘name’
Second, and more perplexing, it’s running the scripts twice. It makes it to the target, then you can see the second “push” after the collision with the target, as it pushes the target a little. Here’s the total output:

shaders not supported!
Starting Tracking Program
On first initializing, Hungry = 1
Chasing = 1
Starting stopchasing.py
colval.isPositive() = 1
Hungry = 0
Chasing = 0
CaughtPrey = 1
Hungry = 0
Starting Tracking Program
On first initializing, Hungry = 0
Chasing = 1
Starting stopchasing.py
colval.isPositive() = 0
PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “stopchasing.py”, line 12, in <module>

AttributeError: ‘NoneType’ object has no attribute ‘name’
Starting stopchasing.py
colval.isPositive() = 1
Hungry = 0
Chasing = 0
CaughtPrey = 1
Hungry = 0
Starting stopchasing.py
colval.isPositive() = 0
PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “stopchasing.py”, line 12, in <module>

AttributeError: ‘NoneType’ object has no attribute ‘name’
Notice that, on the second run of the “Tracking Program” (tracktonearest.py), it says “On first initializing, Hungry = 0” – but the only thing that should be activating the script at all is Hungry = 1. And stopchasing.py is actually called three times at the end; the first time of which colval.isPositive() = 0 (and the script error happens), the second time colval.isPositive() = 1 (and there is no script error) and the third time it is again 0 with a script error.

(As an aside, I’m also a bit curious as to why it feels the to need to tell me that shaders are not supported…)

What am I missing?