Metachs / sdwebui-nai-api

zlib License
22 stars 3 forks source link

Auto wait if hit with 429? #11

Closed Wavuwavu closed 8 months ago

Wavuwavu commented 8 months ago

Hi,

If you leave a long batch on after a while you get hit with "ERROR: Request 1/1 Failed - Error Code:429 Concurrent free generation requests are not allowed" And then it seems it keeps hammering it with requests until it works.

In settings, I see "Maximum time to wait before failing when a free opus request is rejected due to one already in progress." Which I assume is related to this, but it doesn't seem to work? I set it to 120 but I see it keeps retrying every 5–10 seconds anyway.

Just worried the NAI devs won't like me doing this. Thanks.

Metachs commented 8 months ago

That option actually works the other way around, it sets the maximum total time to wait, if you set it to zero, it will disable the wait and retry on 429 errors.

Wavuwavu commented 8 months ago

Sorry, I think you misunderstand? Its what I thought but I think that setting is not working as intended? Like I said I set it to 120 seconds and I see in the console it printing a new retrying line 5 or so seconds anyway, and my worry here is the NAI server having an issue with me doing this.

Metachs commented 8 months ago

Yeah all that setting does is control the total time, the 5 second wait time was hard coded. I just added an extra setting which lets you control wait time between retries for 429 errors, which should fix that. (Haven't actually tested it, since I can't seem to trigger any, but it should work)

Wavuwavu commented 8 months ago

Oh thank you very much, I was confused as I thought that setting what you just added now.

However bad news, when it happens now I get a spam of "ERROR: Request 1/1 Failed - Unhandled Exception: name 'wait_time' is not defined"

Metachs commented 8 months ago

Of course, that should be fixed now.

Wavuwavu commented 8 months ago

Thanks yet again, but still unfortunate news that I'm still seeing it retry every 5ish seconds.

I set "Time to wait between retry attempts after receiving a 429 error (Too many requests)." to 60.

kWZHYHd

The screenshot might be useless but maybe it helps.

Metachs commented 8 months ago

Should work now, actually tested it this time.