ArcGIS crashes during run of python script using cursors

Discussion created by tfleischaker28 on Nov 1, 2012
I am doing processing using a python script to determine how many polygons are adjacent to each of a selected set of polygons. My code...
1. creates a search cursor to find all of the polygons that need updating, then
2. loops through each of those polygons.
3. In the loop it selects the polygon, does a select by location to find all polygons that touch the boundary, then
4. inserts the number of selected polygons into a field in the table for the polygon identified in step 2 using an update cursor. 
This script runs quite well except for once it gets to about the 360th record to update, ArcGIS crashes.  I have tried clearing the search cursor for every x time through the loop, but that has not helped with the problem, I have also tried the garbage collection gc.collect() which also has not fixed the crash.
I need to run this script for about 3000 polygons at a time.
Any suggestions? I would really appreciate it!

....after reading some other posts I have changed my code.  Instead of nesting cursors...updatecursor within a search cursor, I am writing the ids in step 1 into a list and then using a search cursor for each of those in a for loop...i'm testing it now.