Python tool causes arcmap.exe not to close - BUG ?

Discussion created by spiskulaesriuk-esridist Employee on Feb 12, 2013
Latest reply on Feb 12, 2013 by mvolz47

I wrote a very simple geoprocessing python script that after running it and closing ArcMap, the ArcMap.exe process never ends/closes. As a result sometimes it holds locks on SDE featureclasses etc. I've tried this on ArcMap 10 SP5 (on Win7 and WinXP) and ArcMap 10.1 SP1 (on Win7) and it occurs on all configurations. Here is the tool's code:

import arcpy

fc = arcpy.GetParameterAsText(0)


featcur = arcpy.SearchCursor(fc)
#.next() causes problem - arcmap.exe process does not disappear after appilcation window is closed 
f_row = featcur.next()


del f_row
del featcur

arcpy.AddMessage("Mem released")

The problem occurs only for Feature Classes from SDE. In particular I tried MS SQL Express 2005 + Direct Connect, also had the same problem with Oracle and PostgreSQL. It seems OK for .gdb features. The problem seems not to occur with empty SDE feature classes. Also it seems that the problem does not occur under ArcCatalog.

To reproduce:
1.Make sure no ArcMap is running (check under Task Manager / Processes tab)
2.Start clean ArcMap session
3.Open cursorBug tool from the attached CursorTest.tbx
4.Run the tool with any non-empty SDE feature class
5.Once the tool finishes close it and close ArcMap.
6.Check Task Manager / Processes tab. ArcMap.exe prcoess stays there and never closes

The 'cursorOk' tool is just for reference to demonstrate that it all works as expected if the  'f_row = featcur.next()' statement is not present in the code.

Can I have any feedback on this? Or am I missing something? Is there a better way of releasing resources?