<?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: Windows task hangs after server migration to Cloud in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/windows-task-hangs-after-server-migration-to-cloud/m-p/1100068#M62509</link>
    <description>&lt;P&gt;Check if the user you are running the script as (if you are using one) is an admin on the server; Check if the arcpy license is active for that user while not logged in.&amp;nbsp; One issue I had was trying to import another script using 'from &amp;lt;folder&amp;gt; import &amp;lt;module&amp;gt;.&amp;nbsp; Worked in the IDE, but in the task scheduler it failed.&amp;nbsp; Had to use just import &amp;lt;module&amp;gt; for it to work in the task.&lt;/P&gt;&lt;P&gt;You can run some test tasks to get exceptions as well to help troubleshooting.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;try:
    import arcpy
    from arcpy import env
    import os
    import sys
    from datetime import datetime as dt
    from datetime import date, timedelta
    from subprocess import Popen, PIPE

... try other things

except Exception as err:
    # write the err to a log
    f = open(os.path.join(r'c:\Tasks.txt'), "a")
    f.write(err.message)
    f.close()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Sep 2021 19:51:10 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-09-20T19:51:10Z</dc:date>
    <item>
      <title>Windows task hangs after server migration to Cloud</title>
      <link>https://community.esri.com/t5/python-questions/windows-task-hangs-after-server-migration-to-cloud/m-p/1100055#M62507</link>
      <description>&lt;P&gt;We migrated our servers to&amp;nbsp; cloud and it is causing issues with Python scripts.&lt;BR /&gt;Our scripts which have following statement hangs when run from Task Scheduler or Command prompt.&lt;/P&gt;&lt;P&gt;mxdinfo.get_map()&lt;/P&gt;&lt;P&gt;If I run it from IDLE, it completes fine. It only hangs in a command prompt &amp;amp; scheduled task.&lt;BR /&gt;This issue is on all servers migrated to Cloud. I uninstalled/re-installed ArcGIS desktop 10.6 but still same issue.&lt;BR /&gt;Have anyone experienced this issue?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 19:24:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/windows-task-hangs-after-server-migration-to-cloud/m-p/1100055#M62507</guid>
      <dc:creator>TasneemMulla</dc:creator>
      <dc:date>2021-09-20T19:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Windows task hangs after server migration to Cloud</title>
      <link>https://community.esri.com/t5/python-questions/windows-task-hangs-after-server-migration-to-cloud/m-p/1100068#M62509</link>
      <description>&lt;P&gt;Check if the user you are running the script as (if you are using one) is an admin on the server; Check if the arcpy license is active for that user while not logged in.&amp;nbsp; One issue I had was trying to import another script using 'from &amp;lt;folder&amp;gt; import &amp;lt;module&amp;gt;.&amp;nbsp; Worked in the IDE, but in the task scheduler it failed.&amp;nbsp; Had to use just import &amp;lt;module&amp;gt; for it to work in the task.&lt;/P&gt;&lt;P&gt;You can run some test tasks to get exceptions as well to help troubleshooting.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;try:
    import arcpy
    from arcpy import env
    import os
    import sys
    from datetime import datetime as dt
    from datetime import date, timedelta
    from subprocess import Popen, PIPE

... try other things

except Exception as err:
    # write the err to a log
    f = open(os.path.join(r'c:\Tasks.txt'), "a")
    f.write(err.message)
    f.close()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 19:51:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/windows-task-hangs-after-server-migration-to-cloud/m-p/1100068#M62509</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-09-20T19:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Windows task hangs after server migration to Cloud</title>
      <link>https://community.esri.com/t5/python-questions/windows-task-hangs-after-server-migration-to-cloud/m-p/1100134#M62519</link>
      <description>&lt;P&gt;Thanks Jeff for your response. The user I am using is admin also the arcpy license is active.&lt;/P&gt;&lt;P&gt;I checked the script using&amp;nbsp;&lt;SPAN&gt;'from &amp;lt;folder&amp;gt; import &amp;lt;module&amp;gt;' and 'import &amp;lt;module&amp;gt;'. The script behavior&amp;nbsp;is same in both cases , it just hangs and does not exit from the command prompt.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The script is not failing, there is no error , it just not existing from the command prompt and python.exe session remains active unless I kill it forcefully or from task manager.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 22:55:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/windows-task-hangs-after-server-migration-to-cloud/m-p/1100134#M62519</guid>
      <dc:creator>TasneemMulla</dc:creator>
      <dc:date>2021-09-20T22:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Windows task hangs after server migration to Cloud</title>
      <link>https://community.esri.com/t5/python-questions/windows-task-hangs-after-server-migration-to-cloud/m-p/1100145#M62521</link>
      <description>&lt;P&gt;Comment out all of your imports and go one by one uncommenting them and see if any hang.&amp;nbsp; That is how I discovered arcpy wasn't licensed and how the syntax import syntax was not acceptable to tasks scheduler.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 23:32:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/windows-task-hangs-after-server-migration-to-cloud/m-p/1100145#M62521</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-09-20T23:32:36Z</dc:date>
    </item>
  </channel>
</rss>

