So I am calling the SPOTIPY API to add a users song, album, artist, and user_info to a db. The total number of records inserted are around 4,000. The db will update, however after 5 minutes (response_time = 300 seconds) the HTML page will throw a load balancing error. The db continues to update after this error but my webpage is stuck on a error screen.
In the access log I get the following when the error is thrown:
24.154.122.253 - - [23/Apr/2021:19:21:15 +0000] "POST /uploadFile HTTP/1.1" 499 0 "https://spotify365.pythonanywhere.com/upload" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36" "24.154.122.253" response-time=300.003
While the database may not be completed by the time the error is thrown, it is eventually completed after a couple of minutes which leaves me to believe that if i can increase the Flask Apps response time then my program should work.
In an attempt to increase the flask_app's response time I tried:
app.config["SQLALCHEMY_POOL_RECYCLE"] = 600
But that didnt help, which made me try to modify the Spotify client's timeout and retry limit:
spotify = spotipy.Spotify(client_credentials_manager=client_credentials_manager, requests_timeout=600, retries = 2)
This should set the timeout for a Spotipy API request to be 600 seconds, and for the request to be retryed up to 2 times. However I do not believe this is the problem since the DB DOES GET CREATED IN FULL EVENTUALLY