I am currently working on a project that requires using a python/arcpy tool to allow a user to create a map series report PDF. Without getting into much detail, the tool is used when in ArcCatalog or ArcMap where the user uses the interface to select the appropriate parameters. The tool generates a PDF report that includes a title page, table of contents, map series, and various summary reports.

The tool generates a lot of temp files behind the scenes in order to generate the report. Since the user may run the tool several times while in an ArcMap session, these files need to be deleted, so no locks can remain on them when the tool is completed. I had no problems with the locks being removed, until I added a dynamic table to the map series MXD that uses the "production mapping" extension.

The table updates for each map page based on the features of interest on each map page. Once I added this table, the features in the map series mxd are locked in the file geodatabase even after the python tool ends (and I made sure that the mxd variable is deleted).

So my question is why won't the MXD "close" now that I added this dynamic table? Thanks for any help.

  • Take a look at this post and this resrouce by ESRI. Looks like there may be a few things going on: 1) References to objects are not being removed, 2) locks may be 'hanging around' a bit after your tool has finished doing its thing. You can maybe try using the "in_memory" object for your temp files as I think this will help in managing those files.
    – dchaboya
    Commented Jul 10, 2013 at 18:09

1 Answer 1


I run into problems like this when I am debugging script in pyCharm. Mostly its because I have accidentally spawned two debugging sessions. However, if the data needs to be deleted after the script runs, you might be best off using scratch gdb/folders/workspace to hold the data. Here is an example of pairing scratch folder with uuid to get a unique object name:

import uuid
import os
output = 'WebMap_{}.{}'.format(str(uuid.uuid1()), Format)
Output_File = os.path.join(arcpy.env.scratchFolder, output)

http://resources.arcgis.com/en/help/main/10.1/index.html#/Scratch_Workspace/001w00000003000000/ http://resources.arcgis.com/en/help/main/10.1/index.html#/Scratch_GDB/001w00000047000000/ http://resources.arcgis.com/en/help/main/10.1/index.html#/Scratch_GDB/001w00000047000000/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.