Select to view content in your preferred language

"Future" parameter in FeatureLayer methods implementation seems pointless?

548
2
10-12-2022 04:29 PM
SamSzotkowski
Regular Contributor

Related: https://community.esri.com/t5/arcgis-api-for-python-questions/is-there-an-example-for-how-to-use-the...

I went into the source code to try and figure out how setting "future=True" behaved in various methods for arcgis.features.FeatureLayer objects, such as delete_features() or edit_features().  Here's a snippet from the end of delete_features(), found in ~env\Lib\site-packages\arcgis\features\layer.py:

 

if future is False:
    return self._con.post(path=delete_url, postdata=params)
else:
    params["async"] = True
    import concurrent.futures

    executor = concurrent.futures.ThreadPoolExecutor(1)
    res = self._con.post(path=delete_url, postdata=params)
    time.sleep(2)
    future = executor.submit(
        self._status_via_url,
        *(self._con, res["statusUrl"], {"f": "json"}),
    )
    executor.shutdown(False)

    return future

 

Somebody please correct me if I'm wrong, but isn't this implementation of a concurrent.futures.ThreadPoolExecutor pointless?  Whether it's edit_features() or delete_features() or whatever, they're all only sending a single http POST request at the end of the day, and they all create only a single thread.  As I understand it, the ThreadPoolExecutor will block the rest of the program until all its threads (well, just one here) finish and join back together.  I'm also not sure the motivation behind the 2 second sleep.

Am I misunderstanding something?  It seems like maybe they should instead be returning us all the stuff they pass to executor.submit() so that we can put together our own thread pool and send a bunch of requests at once.

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

A good place to post an "Issue" or Question which is more target to the team

Esri/arcgis-python-api: Documentation and samples for ArcGIS API for Python (github.com)


... sort of retired...
0 Kudos
SamSzotkowski
Regular Contributor

Thank you, I'll consider posting there after I solidify my understanding a bit more, but there's not much info out there so I'm hoping someone in this community has actually used these parameters and either got it to work or came to the same conclusion as me.

0 Kudos