Select to view content in your preferred language

Getting "Your request has timed out" 504 error code exception in ArcGIS API for Python

3311
1
Jump to solution
12-20-2021 04:11 PM
davedoesgis
Frequent Contributor

Hi, I have a request to update a hosted feature layer item definition with the ArcGIS API for Python. This has worked for a long time with no issues, but just started intermittently failing. The code looks like this: 

 

gis = arcgis.GIS(profile="<profile_name>")
item = gis.get_item_by_id("<item_id>")
collection = FeatureLayerCollection.fromitem(item)
overwrite_result = collection.manager.overwrite(zipfile_path)
update_dict = {"capabilities": "Query", "syncEnabled": True}
collection.manager.update_definition(update_dict)

 

The last line intermittently fails. I get a python Exception with this message (on two lines, as shown): 

Exception: Your request has timed out.
(Error Code: 504)

Like I said, this has worked for a long time, and just started recently. I have 10 hosted feature layers with identical schemas, but the error only happens on some of them, so it's not just a syntax error. What's really weird is that if I skip the overwrite command (line 4, above), I cannot replicate this Exception. I wonder if the hosted feature layer is occasionally getting locked by the overwrite. 

 

Note - I did see this related issue , but all my hosted feature layers are the same, so it doesn't make sense that some would fail while others succeed. 

 

 

0 Kudos
1 Solution

Accepted Solutions
SimonGIS
Regular Contributor

Long shot, but I had intermittent issues with 504s when running some scripts against an org with a large amount of content.  

Not sure if it is documented, but adding this expiration property to the GIS object fixed it for me:

gis = GIS(profile='yourprofilecreds', expiration=9999)

 

View solution in original post

1 Reply
SimonGIS
Regular Contributor

Long shot, but I had intermittent issues with 504s when running some scripts against an org with a large amount of content.  

Not sure if it is documented, but adding this expiration property to the GIS object fixed it for me:

gis = GIS(profile='yourprofilecreds', expiration=9999)