Esri / Esri/arcgis-python-api

Requests in internal functions to a non-working ArcGIS Server services causes execution freeze

Open
#1,231 9 comments 1 reaction 1 assignee Claimed by @achapkowski View on GitHub
bug
Dominant language
Python
Stars
2.2k
Forks
1.2k
Avg merge
2h 40m
Merged PRs (30d)
2

Description

**Describe the bug**
Accessing some properties or methods on an Item object where the underlying FeatureServer or MapServer is not working will cause an infinite freeze.
This boils down to a self._con.post call in the self._refresh method of the Item object.
The reason, in our case, for the service not working was a deleted table in the database.
Perhaps this can be considered an edge case.
Tested with 2.0.0 of the API

**To Reproduce**
Steps to reproduce the behavior:

1. Publish a service which uses an enterprise geodatabase to ArcGIS Server
2. If necessary, add an item in Portal referencing the service published in step 1
3. Delete the underlying feature class from the enterprise geodatabase. This may need to be done in SQL Server Management Studio (or similar) or disable schema locking at the service in AGS Manager, if not able to delete it from ArcGIS Pro/ArcMap.
4. Make sure the service is still running
5. Run the code below

```python
from arcgis.gis import GIS
gis = GIS(portal_url, username, password)
item = gis.content.get("")
print(item.shared_with)
```
error:
it just sits there, waiting. To end, kill the python process/kernel.

**Expected behavior**
I expect the Python API to throw an error (perhaps by adding a timeout value to the post request).

**Platform (please complete the following information):**
- OS: Windows 10
- Python API Version 2.0.0
- Python 3.7.11 from ArcGIS Pro 2.9.2

**Additional context**
I've tracked down the request freezing to the line below (in my case, where the Item was a Feature Service)
Line 14549 in the file \Lib\site-packages\arcgis\gis\__init__.py

```python
dictdata = self._con.post(
self.url, params
)
```

A bit more context, starting at line 14541
```python
else:
try:
if is_raster:
dictdata = self._con.post(
self.url, params, timeout=None # token=self._lazy_token,
)
else:
try:
dictdata = self._con.post(
self.url, params
) # , token=self._lazy_token)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.