I have a Python script using the latest ArcGIS Python API version 1.8.3. Its objective is to search a municipal code violation database in AGOL and identify tall grass violations that require a notice to be sent, and then also identify violations that have already received a notice, are overdue, and must be mowed by the municipality (also generates the notices themselves as well as a mowing list). It uses multiple queries of an AGOL parcel feature service and queries of related records in a code violation table that is related to the parcel feature service. The script has worked well for over a year.
Within the past couple of weeks, I have begun receiving a 504 error (gateway timeout) that kills the script during the last query_related_records function. I have to re-run this section of the script several times, and it eventually works without the timeout (I had to extract this section of the script into a separate script and run it repeatedly). I checked with our IT dept. and they think the timeout is happening on the AGOL end, not our network. Any ideas as to what might be causing the connection timeout, and how to resolve it?