The indexing by collision_type sometimes fails with a KeyError:
def handle_collision(arbiter, space, data):
shape1 = shapes[arbiter.shapes[0].collision_type]
shape2 = shapes[arbiter.shapes[1].collision_type]
p = arbiter.contact_point_set.points[0].point_a

It looks like what's happening is that two collisions are happening in the same frame for the same object. The first collision deactivated the object, which let to the KeyError when trying to handle the second collision.
Putting a try/except in to handle the KeyError seems reasonable.
The indexing by collision_type sometimes fails with a KeyError:
It looks like what's happening is that two collisions are happening in the same frame for the same object. The first collision deactivated the object, which let to the KeyError when trying to handle the second collision.
Putting a try/except in to handle the KeyError seems reasonable.