I have a Python script that is looping through a list of feature classes stored in a config file. It is exporting the metadata for each feature class using the methodology in the answer posted to Creating table containing all filenames (and possibly metadata) in File Geodatabase?

The script runs as expected, however, when performance testing I'm finding that the first time the MetadataImporter_conversion command is executed, it is taking approximately 60 seconds to complete. On subsequent iterations the same command takes less than a second to complete.

I have tried re-ordering the feature classes within the config file to test if the issue is being caused by a particular feature class, but it had no impact. The first feature class in the list takes 60 times longer to process than the ones that follow.

Ultimately this script will be incorporated into a Geocortex workflow, so I'm trying to make it as efficient as possible so that the user doesn't have to hang around waiting for the results to be returned.

This is a snippit of the code I'm using:

# ---------------------------------------------------------------------------
def CreateDummyXMLFile():
    filepath = r"e:\temp\tmpXML.xml" # This path is for testing purposes only
    with open(filepath, "w") as f:
        f.write("<metadata />")

    return filepath
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
    def GetElementText(tree, elementPath):
    """Returns the specified element's text if it exists or an empty
    string if not."""    
        element = tree.find(elementPath)
        return element.text if element != None else ""
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
def GetMetadataElementTree(dataset):
    """Creates and returns an ElementTree object from the specified
    dataset's metadata"""
    xmlfile = CreateDummyXMLFile()
    arcpy.MetadataImporter_conversion(dataset, xmlfile)
    tree = ElementTree()
    return tree
# ---------------------------------------------------------------------------

for aIntersect in ListOfFeatureClasses:
    xmlfile = CreateDummyXMLFile()
    tree = GetMetadataElementTree(aIntersect)
    aTitle = GetElementText(tree, "dataIdInfo/idCitation/resTitle") # Title
    aPubDate = GetElementText(tree, "dataIdInfo/idCitation/date/pubDate") # Publication Date
    print "      Title: {}".format(aTitle)
    print "      Date: {}".format(aPubDate)
    del tree

Processing times with baam feature class as the first item in the list: enter image description here

Processing times with esa_c feature class as the first item in the list: enter image description here

Can someone explain this behaviour or replicate it?

Testing on my personal PC running has not been able to replicate the issue. Would be interested to know if this issue is related to or perhaps just isolated to my work PC.

closed as off-topic by PolyGeo Feb 19 at 6:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.


Testing with all data hosted on my PC (rather than accessing over the network) replicated the issue, with similar processing times.

Further testing with all data hosted on a geoprocessing server revealed times of less than a second for all iterations.

The conclusion is that the issue is isolated to my PC, however, what's causing it is still undetermined.

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