I'm having trouble with [504 Server Error: Gateway Timeout for] with Graph API

240 Views Asked by At

I'm trying to use O365 (Python) to calculate an excel file located on OneDrive. But it results in "504 Server Error: Gateway Timeout for" due to the large size of the file.

In the browser, the result is obtained by calculating the sheet in order with "Calculate sheet".

Does anyone know how to increase connection time or "calculate sheets"?

Thank you.

excel_file = WorkBook(file_instance, persist=True) 
wb_app = excel_file.get_workbookapplication()
wb_app.run_calculations("Recalculate")

--> 504 timeout error...
1

There are 1 best solutions below

0
On

I self-solved. It seems that it can be calculated by retrying several times. I'll take a look at it this way.

i=0
while i<10:
    try:
        res = wb_app.run_calculations("Recalculate")
    except Exception as e:
        print(f"Error Occurred(calculate): {e}")
        res = False
    
    if res==True:
        break
    else:
        time.sleep(5)

    i+=1