<?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: How to check on cache job status in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1629114#M74460</link>
    <description>&lt;P&gt;Most arcpy passthrough functions return a Result object. Those objects have a status value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: I see that the sharing function returns some REST endpoints. Can you ping those to test for completion? Just have a while loop that checks for 200 status at the endpoint?&lt;/P&gt;</description>
    <pubDate>Tue, 01 Jul 2025 22:58:44 GMT</pubDate>
    <dc:creator>HaydenWelch</dc:creator>
    <dc:date>2025-07-01T22:58:44Z</dc:date>
    <item>
      <title>How to check on cache job status</title>
      <link>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1628854#M74456</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to automate uploading my scene services.&lt;BR /&gt;I tried the "new" way to publish them with pyhton like in this documentation:&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/publish.htm" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/publish.htm&lt;/A&gt;&lt;BR /&gt;The upload works fine, but I have to wait till the cache generation is finished, before I can upload additional data.&lt;BR /&gt;Otherwise my server will be overloaded.&lt;BR /&gt;Some of the services take 1 hour to complete the cache generation, other take up to 14 hours.&lt;BR /&gt;So I want to check the job status, the cache_job_id is even returned by the example of esri, but I cant find a way to check for this job.&lt;BR /&gt;Can anyone link me the right documentions or an example?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2025 13:57:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1628854#M74456</guid>
      <dc:creator>SebastianBosbach</dc:creator>
      <dc:date>2025-07-01T13:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to check on cache job status</title>
      <link>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1628945#M74457</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/270624"&gt;@SebastianBosbach&lt;/a&gt;&amp;nbsp; , in ArcGIS Server Manager you can click on this View Cache Status button. Does that tell you what you need to know ?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisUnderwood_0-1751386988007.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/135521iAC9DD2C8B232DEA9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisUnderwood_0-1751386988007.png" alt="ChrisUnderwood_0-1751386988007.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2025 16:23:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1628945#M74457</guid>
      <dc:creator>ChrisUnderwood</dc:creator>
      <dc:date>2025-07-01T16:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to check on cache job status</title>
      <link>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1629114#M74460</link>
      <description>&lt;P&gt;Most arcpy passthrough functions return a Result object. Those objects have a status value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: I see that the sharing function returns some REST endpoints. Can you ping those to test for completion? Just have a while loop that checks for 200 status at the endpoint?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2025 22:58:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1629114#M74460</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-07-01T22:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to check on cache job status</title>
      <link>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1629244#M74461</link>
      <description>&lt;P&gt;No. First the cache job status of a scene layer isn't shown there. Second I need to automate the polling of the job with python, so even if the status would be shown there, going manual to the server manager wouldn't be my solution.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2025 07:36:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1629244#M74461</guid>
      <dc:creator>SebastianBosbach</dc:creator>
      <dc:date>2025-07-02T07:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to check on cache job status</title>
      <link>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1629245#M74462</link>
      <description>&lt;P&gt;Hi, thats exactly what I want to to.&lt;BR /&gt;From the documentation: "Returns a dictionary that includes the item URL, REST URL, and cache job ID."&lt;BR /&gt;But there is no additional info on how to use the job ID to get the job status, thats the thing I'm looking for help on.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2025 07:41:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1629245#M74462</guid>
      <dc:creator>SebastianBosbach</dc:creator>
      <dc:date>2025-07-02T07:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to check on cache job status</title>
      <link>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1631029#M74480</link>
      <description>&lt;P&gt;I now implemented a "dirty" way to check for the cache job, because I still don't know where to check for the job with the job_id provided by the publish function .&lt;BR /&gt;&lt;BR /&gt;If someone else might find this thread, this is how I check if the cache job is still running:&lt;/P&gt;&lt;P&gt;- publish the scene layer&lt;BR /&gt;- get the scene layer uri&lt;BR /&gt;- check in loop if propertie "lastUpdate" has a value different then "-999999"&lt;BR /&gt;- if so, cache generation is finished&lt;BR /&gt;- publish the next scene layer&lt;/P&gt;&lt;P&gt;This script only checks on one layer of the published data ("/layers/0"), if your data would have more then one scene layer, you need to edit this.&lt;/P&gt;&lt;P&gt;I still would appreciate it, if someone would point me to the "right" way on checking the cache status using the job_id.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def get_token(server_url, username, password):
    url = f"{server_url}/admin/generateToken"
    data = {
        "username": username,
        "password": password,
        "client": "requestip",
        "f": "json"
    }
    r = requests.post(url, data=data, verify=False)
    r.raise_for_status()
    return r.json()["token"]


def get_layer_last_update(layer_url, token):
    params = {"f": "json", "token": token}
    r = requests.get(layer_url, params=params, verify=False)
    r.raise_for_status()
    layer_info = r.json()
    return layer_info.get("serviceUpdateTimeStamp", {}).get("lastUpdate", -999999)

#...
#generate aprx an stuff to publish data
#...

    res = arcpy.sharing.Publish(scene_draft)

    print(r"item_url: " + res["web_scene_layer"]["item_url"])
    print(r"rest_url: " + res["web_scene_layer"]["rest_url"])
    print(r"cache_job_id: " + res["web_scene_layer"]["cache_job_id"])

    timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    print(f"[{timestamp}] Finish Publishing {bu}")

    layer_url = res["web_scene_layer"]["rest_url"] + r"/layers/0"
    token = get_token(server_url, username, password)
    token_expires = datetime.now() + timedelta(minutes=30)

    while True:
        try:

            #refresh token after 30 minutes
            if datetime.now() &amp;gt;= token_expires:
                token = get_token(server_url, username, password)
                token_expires = datetime.now() + timedelta(minutes=30)

            last_update = get_layer_last_update(layer_url, token)
            timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            status_text = f"[{timestamp}] 🔍 cache generation still running (lastUpdate = {last_update})"

            print(status_text.ljust(100), end="\r")  # Zeile überschreiben

            if last_update != -999999:
                print(f"\n✅ cache generation finished (lastUpdate = {last_update})")
                break

        except Exception as e:
            print(f"❗ error fetching lastUpdate: {e}")
            break

        time.sleep(60)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jul 2025 08:42:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-check-on-cache-job-status/m-p/1631029#M74480</guid>
      <dc:creator>SebastianBosbach</dc:creator>
      <dc:date>2025-07-08T08:42:37Z</dc:date>
    </item>
  </channel>
</rss>

