mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-10 05:34:25 +00:00
Misc
This commit is contained in:
@@ -1937,21 +1937,22 @@ namespace ArchiSteamFarm {
|
|||||||
return await function().ConfigureAwait(false);
|
return await function().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sending a request affects both - number of requests as well as open connections
|
// Sending a request opens a new connection
|
||||||
await limiters.RateLimitingSemaphore.WaitAsync().ConfigureAwait(false);
|
|
||||||
await limiters.OpenConnectionsSemaphore.WaitAsync().ConfigureAwait(false);
|
await limiters.OpenConnectionsSemaphore.WaitAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
// We release rate-limiter semaphore regardless of our task completion, since we use that one only to guarantee rate-limiting of their creation
|
|
||||||
Utilities.InBackground(async () => {
|
|
||||||
await Task.Delay(Program.GlobalConfig.WebLimiterDelay).ConfigureAwait(false);
|
|
||||||
limiters.RateLimitingSemaphore.Release();
|
|
||||||
});
|
|
||||||
|
|
||||||
// However, we release open connections semaphore only once we're indeed done sending a particular request
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// It also increases number of requests
|
||||||
|
await limiters.RateLimitingSemaphore.WaitAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
// We release rate-limiter semaphore regardless of our task completion, since we use that one only to guarantee rate-limiting of their creation
|
||||||
|
Utilities.InBackground(async () => {
|
||||||
|
await Task.Delay(Program.GlobalConfig.WebLimiterDelay).ConfigureAwait(false);
|
||||||
|
limiters.RateLimitingSemaphore.Release();
|
||||||
|
});
|
||||||
|
|
||||||
return await function().ConfigureAwait(false);
|
return await function().ConfigureAwait(false);
|
||||||
} finally {
|
} finally {
|
||||||
|
// We release open connections semaphore only once we're indeed done sending a particular request
|
||||||
limiters.OpenConnectionsSemaphore.Release();
|
limiters.OpenConnectionsSemaphore.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user