<?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 use arcpy environment settings with python multiprocessing in arcgis pro? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-use-arcpy-environment-settings-with-python/m-p/1717283#M75354</link>
    <description>&lt;P&gt;arcpy in general does not play well with multiprocessing since the underlying C code is not written to be threadsafe (sometimes). There's a lot of blocking behavior in the function calls and the library needs to be loaded into each process (something that will often also cause license check errors).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have had much better luck with the concurrent.futures ThreadPoolExecutor though in the past:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import concurrent.futures as fut

from arcpy.da import SearchCursor

gdb = r'&amp;lt;gdb&amp;gt;\{}'
fcs = ['FC1', 'FC2', 'FC3', 'FC4'] * 5


def read(fc: str) -&amp;gt; list[dict[str, object]]:
    rows = list[tuple[object, ...]]()
    fields = list[str]()
    with SearchCursor(gdb.format(fc), '*') as cur:
        fields = cur.fields
        rows = list(cur)
    return [dict(zip(fields, row, strict=True)) for row in rows]


def mp_run(workers: int = 3):
    with fut.ThreadPoolExecutor(workers, initializer=lambda: globals()) as pool:
        return [
            f.result()
            for f in fut.as_completed(pool.submit(read, fc) for fc in fcs)
        ]


def run():
    return [read(fc) for fc in fcs]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This does not work with everything though. There is also almost no speedup for most operations since the root arcpy process maintains all the locks and won't release them until an operation completes.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jul 2026 13:58:52 GMT</pubDate>
    <dc:creator>HaydenWelch</dc:creator>
    <dc:date>2026-07-29T13:58:52Z</dc:date>
    <item>
      <title>How to use arcpy environment settings with python multiprocessing in arcgis pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-arcpy-environment-settings-with-python/m-p/1714190#M75337</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I want to use arcpy environment settings with python mutliprocessing, but using attribut 'workspace' raises the exception:&amp;nbsp;"AttributeError: 'GPEnvironment' object has no attribute 'workspace'"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My code snippet from parent script:&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;mp_exe = os.path.join(sys.exec_prefix, 'pythonw.exe')&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;mp.set_executable(mp_exe)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;with mp.Pool(4) as pool:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; pool.starmap(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mp_update,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [("some_sde_connection_file", tbl_name) for tbl_name in tbl_names],&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;STRONG&gt;My code snippet from multiprocessing script:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;def mp_update(cnn_file, tbl_name):&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; arcpy.env.workspace = cnn_file&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; pass&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I tested bove arcpy.env.workspace and arcpy.EnvManager(Workspace=...).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;The exception "AttributeError: 'GPEnvironment' object has no attribute 'workspace'" is always raised wenn das Skript als Skript-Tool in ArcGIS Pro (3.4.5) ausgeführt wird.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;But the script executes successfully without an exception in my development environment (PyScripter).&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Does anyone have an idea why arcpy environment settings are unavailable during multiprocessing?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2026 13:12:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-arcpy-environment-settings-with-python/m-p/1714190#M75337</guid>
      <dc:creator>JörgEbert</dc:creator>
      <dc:date>2026-07-13T13:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to use arcpy environment settings with python multiprocessing in arcgis pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-arcpy-environment-settings-with-python/m-p/1717283#M75354</link>
      <description>&lt;P&gt;arcpy in general does not play well with multiprocessing since the underlying C code is not written to be threadsafe (sometimes). There's a lot of blocking behavior in the function calls and the library needs to be loaded into each process (something that will often also cause license check errors).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have had much better luck with the concurrent.futures ThreadPoolExecutor though in the past:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import concurrent.futures as fut

from arcpy.da import SearchCursor

gdb = r'&amp;lt;gdb&amp;gt;\{}'
fcs = ['FC1', 'FC2', 'FC3', 'FC4'] * 5


def read(fc: str) -&amp;gt; list[dict[str, object]]:
    rows = list[tuple[object, ...]]()
    fields = list[str]()
    with SearchCursor(gdb.format(fc), '*') as cur:
        fields = cur.fields
        rows = list(cur)
    return [dict(zip(fields, row, strict=True)) for row in rows]


def mp_run(workers: int = 3):
    with fut.ThreadPoolExecutor(workers, initializer=lambda: globals()) as pool:
        return [
            f.result()
            for f in fut.as_completed(pool.submit(read, fc) for fc in fcs)
        ]


def run():
    return [read(fc) for fc in fcs]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This does not work with everything though. There is also almost no speedup for most operations since the root arcpy process maintains all the locks and won't release them until an operation completes.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2026 13:58:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-arcpy-environment-settings-with-python/m-p/1717283#M75354</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2026-07-29T13:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to use arcpy environment settings with python multiprocessing in arcgis pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-arcpy-environment-settings-with-python/m-p/1717359#M75355</link>
      <description>&lt;P&gt;Using pythonw.exe instead of python.exe eliminates standard communication streams between the parent and child, which commonly applications rely on to pass state and environment information to the spawned children.&amp;nbsp; I would start by just switching to python.exe.&amp;nbsp; Since you are running this as a script tool, a console window won't be opened anyways.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2026 16:26:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-arcpy-environment-settings-with-python/m-p/1717359#M75355</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2026-07-29T16:26:00Z</dc:date>
    </item>
  </channel>
</rss>

