Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with multiple function calls in sheets #37

Open
carlos-ferrer opened this issue Sep 18, 2021 · 2 comments
Open

Working with multiple function calls in sheets #37

carlos-ferrer opened this issue Sep 18, 2021 · 2 comments

Comments

@carlos-ferrer
Copy link

I have a worksheet with 100+ requests to an API; it works ok the first time I set it up, but returns a 429 error as soon as it auto-refreshes. since it tries refreshing every occurance of the function at the same time. I can't do just one request because the way the api organizes the data.
Is it possible to set up a delay so that Sheets doesn't try refreshing multiple instances of this function at the same time?

@gadget78
Copy link

gadget78 commented Oct 3, 2021

yes i have this issue too on occasion, along with "urlfetch exceeding" problems . i just cannot get over it seems :(

@carlos-ferrer
Copy link
Author

Ok, I think I found a workaround using Lock.
Write this Inside do_import_ function (else at line 70):

else {
let lock = LockService.getScriptLock();
lock.waitLock(15000);
json = do_fetch_(url, params);
lock.releaseLock();
    } 

This prevents multiple functions from trying to fetch data at the same time - it locks the formulae for a maximum time of 15 seconds (can lower or increase depending on amount of data, too little time and it returns a lock timeout error).

Before doing this most of the data would return a 429; hasn't happened once after I added the lines above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants