9.3sp1
In ArcCatalog, to disconnect from an SDE database, one simply right-clicks on the connection file and chooses disconnect. The database is closed and the .sde file goes back to having a red mark next to it.
I have not been able to achieve the same functionality using the python geoprocessing environment.
The code basically looks like this:
gp = arcgisscripting.create(9.3)
connection = ('/path/to/connection.sde')
gp.workspace = connection
# do some stuff
# when done doing some stuff, try to disconnect:
gp.ClearWorkspaceCache(connection)
gp.workspace = ""
gp = None
Even when the script cleanly exists, the connection remains active.
When I loop through dozens of databases, none of them disconnect and I have dozens of hung connections to dozens of sde databases, and users complaining that I have an active connection to their database, and ask me to please disconnect from it. I've had to tell them that I can't.
Ideas?