<?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 Re: Geoprocessing Service not seeing newly added data unless restarted or republished? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/geoprocessing-service-not-seeing-newly-added-data/m-p/688322#M53294</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suspect the issue is with the SearchCursor not being disposed of on completion of it's duties. if you aren't preceding the search cursor with a "with" like this:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN class="k" style="color: #0000ff;"&gt;with&lt;/SPAN&gt; &lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;da&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;SearchCursor&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;fc&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;fields&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="k" style="color: #0000ff;"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;cursor&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN class="p"&gt;:&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;then you'll need to be sure to do del on the variable assigned to the cursor. like this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN style="font-family: monospace;"&gt;cursor &lt;/SPAN&gt;= &lt;SPAN class="n" style="font-family: monospace;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="font-family: monospace;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="font-family: monospace;"&gt;da&lt;/SPAN&gt;&lt;SPAN class="o" style="font-family: monospace;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="font-family: monospace;"&gt;SearchCursor&lt;/SPAN&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n" style="font-family: monospace;"&gt;fc&lt;/SPAN&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-family: monospace;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="font-family: monospace;"&gt;fields&lt;/SPAN&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;for row in cursor:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;del cursor&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;you can also try in the same script simultaneously to get the count using arcpy.GetCount_management(fc) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;to see if the issue is with the cursor or with the connection.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;here's a link to the getcount_management help page: &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000n7000000" title="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000n7000000"&gt;ArcGIS Desktop&lt;/A&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Nov 2014 13:52:58 GMT</pubDate>
    <dc:creator>DallasShearer</dc:creator>
    <dc:date>2014-11-06T13:52:58Z</dc:date>
    <item>
      <title>Geoprocessing Service not seeing newly added data unless restarted or republished?</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-not-seeing-newly-added-data/m-p/688321#M53293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Geoprocessing Service that is complicated, but the issue I'm having revolves around a few very simple steps. I'm trying to take in a path to a feature class that sits within SDE, create a temporary feature layer out of it (arcpy.MakeFeatureLayer_management), and then use a search cursor (arcpy.da.SearchCursor) to count the records in the feature class. I am not using ArcMap or anything outside of arcpy for this, the layer is stored in-memory and dumped after being used. The script itself works fine up until the point that new data is added and then the results become inconsistent with the actual data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example of the issue:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Feature Class has 0 records.&lt;/LI&gt;&lt;LI&gt;The Model behind the Geoprocessing Service is run through ArcCatalog/ArcMap and returns a count of "0 records found." (OK)&lt;/LI&gt;&lt;LI&gt;The Geoprocessing Service itself also returns "0 records found." (OK)&lt;/LI&gt;&lt;LI&gt;1 record is added to the Feature Class through some means in an edit session (programatically, through ArcMap, etc.)&lt;/LI&gt;&lt;LI&gt;The model behind the Geoprocessing Service is run through ArcCatalog/ArcMap and still returns a count of "0 records found." (INCORRECT)&lt;/LI&gt;&lt;LI&gt;The Geoprocessing Service itself also returns "0 records found." (INCORRECT)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only way I've discovered that the model will display the correct record count when run from Desktop is to close/open all ArcGIS Desktop applications and re-run it. Likewise, for the Geoprocessing Service to display the correct record count, I must restart or republish the Geoprocessing Service. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm hoping this issue has a simple resolution, but I'm scratching my head over it as of right now. If someone needs sample code, I can provide it, but the first paragraph is the script in a nutshell.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 18:56:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-not-seeing-newly-added-data/m-p/688321#M53293</guid>
      <dc:creator>DominickAlfonso</dc:creator>
      <dc:date>2014-11-05T18:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service not seeing newly added data unless restarted or republished?</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-not-seeing-newly-added-data/m-p/688322#M53294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suspect the issue is with the SearchCursor not being disposed of on completion of it's duties. if you aren't preceding the search cursor with a "with" like this:&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN class="k" style="color: #0000ff;"&gt;with&lt;/SPAN&gt; &lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;da&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;SearchCursor&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;fc&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;fields&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="k" style="color: #0000ff;"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;cursor&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN class="p"&gt;:&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;then you'll need to be sure to do del on the variable assigned to the cursor. like this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN style="font-family: monospace;"&gt;cursor &lt;/SPAN&gt;= &lt;SPAN class="n" style="font-family: monospace;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="font-family: monospace;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="font-family: monospace;"&gt;da&lt;/SPAN&gt;&lt;SPAN class="o" style="font-family: monospace;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="font-family: monospace;"&gt;SearchCursor&lt;/SPAN&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n" style="font-family: monospace;"&gt;fc&lt;/SPAN&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-family: monospace;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="font-family: monospace;"&gt;fields&lt;/SPAN&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;for row in cursor:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;del cursor&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;you can also try in the same script simultaneously to get the count using arcpy.GetCount_management(fc) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;to see if the issue is with the cursor or with the connection.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;here's a link to the getcount_management help page: &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="p"&gt;&lt;SPAN class="p" style="font-family: monospace;"&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000n7000000" title="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000n7000000"&gt;ArcGIS Desktop&lt;/A&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Nov 2014 13:52:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-not-seeing-newly-added-data/m-p/688322#M53294</guid>
      <dc:creator>DallasShearer</dc:creator>
      <dc:date>2014-11-06T13:52:58Z</dc:date>
    </item>
  </channel>
</rss>

