<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python causing schema lock on aprx in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-causing-schema-lock-on-aprx/m-p/1132522#M63472</link>
    <description>&lt;P&gt;More often than not, python seems to be locking up my aprx after executing scripts.&amp;nbsp; Opening ArcGIS Pro following script execution results in a schema lock.&amp;nbsp; My script deletes the aprx as recommended but is there something else I need to do.&amp;nbsp; Typically, I have not been saving the aprx so the aprx.save() is usually omitted.&amp;nbsp; The scripts are ran outside of ArcGIS Pro in a standalone Jupyter Notebook environment.&lt;/P&gt;&lt;P&gt;The following snippet is recommended in the documentation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject(&amp;lt;PATH&amp;gt;)
mp = aprx.listMaps(&amp;lt;MAP NAME&amp;gt;)[0]
&amp;lt;DO SOMETHING&amp;gt;
aprx.save()
del aprx&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm wondering if the following context manager would work better, but am not seeing anything in the documentation.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.mp.ArcGISProject(&amp;lt;PATH&amp;gt;) as aprx:
    mp = aprx.listMaps(&amp;lt;MAP NAME&amp;gt;)[0]
    &amp;lt;DO SOMETHING&amp;gt;
    aprx.save()&lt;/LI-CODE&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Tyler&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jan 2022 17:26:04 GMT</pubDate>
    <dc:creator>TylerT</dc:creator>
    <dc:date>2022-01-11T17:26:04Z</dc:date>
    <item>
      <title>Python causing schema lock on aprx</title>
      <link>https://community.esri.com/t5/python-questions/python-causing-schema-lock-on-aprx/m-p/1132522#M63472</link>
      <description>&lt;P&gt;More often than not, python seems to be locking up my aprx after executing scripts.&amp;nbsp; Opening ArcGIS Pro following script execution results in a schema lock.&amp;nbsp; My script deletes the aprx as recommended but is there something else I need to do.&amp;nbsp; Typically, I have not been saving the aprx so the aprx.save() is usually omitted.&amp;nbsp; The scripts are ran outside of ArcGIS Pro in a standalone Jupyter Notebook environment.&lt;/P&gt;&lt;P&gt;The following snippet is recommended in the documentation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject(&amp;lt;PATH&amp;gt;)
mp = aprx.listMaps(&amp;lt;MAP NAME&amp;gt;)[0]
&amp;lt;DO SOMETHING&amp;gt;
aprx.save()
del aprx&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm wondering if the following context manager would work better, but am not seeing anything in the documentation.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.mp.ArcGISProject(&amp;lt;PATH&amp;gt;) as aprx:
    mp = aprx.listMaps(&amp;lt;MAP NAME&amp;gt;)[0]
    &amp;lt;DO SOMETHING&amp;gt;
    aprx.save()&lt;/LI-CODE&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Tyler&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 17:26:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-causing-schema-lock-on-aprx/m-p/1132522#M63472</guid>
      <dc:creator>TylerT</dc:creator>
      <dc:date>2022-01-11T17:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python causing schema lock on aprx</title>
      <link>https://community.esri.com/t5/python-questions/python-causing-schema-lock-on-aprx/m-p/1132557#M63473</link>
      <description>&lt;P&gt;If you close your notebook, does the lock go away?&lt;/P&gt;&lt;P&gt;If you tried the "with" context manager approach, did you notice any difference?&lt;/P&gt;&lt;P&gt;I suspect it may be the "do something" section the persists the lock&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 18:55:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-causing-schema-lock-on-aprx/m-p/1132557#M63473</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-01-11T18:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python causing schema lock on aprx</title>
      <link>https://community.esri.com/t5/python-questions/python-causing-schema-lock-on-aprx/m-p/1163252#M64323</link>
      <description>&lt;P&gt;All,&lt;/P&gt;&lt;P&gt;After some more experimenting, it seems the del aprx doesn't fully release the lock, however, once the python kernel is stopped the lock is released.&amp;nbsp; So, I'm getting into the habit of stopping or restarting the kernel should I need to run a series of scripts or GUI operations.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tyler&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 20:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-causing-schema-lock-on-aprx/m-p/1163252#M64323</guid>
      <dc:creator>TylerT</dc:creator>
      <dc:date>2022-04-11T20:48:18Z</dc:date>
    </item>
  </channel>
</rss>

