mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-20 00:43:36 +03:00
fix(scheduled events update): run update synchronously to avoid rate limit race conditions
This commit is contained in:
parent
804bcd6e68
commit
f4387deef7
1 changed files with 2 additions and 7 deletions
|
@ -34,20 +34,15 @@ public sealed class ScheduledEventUpdateService : BackgroundService
|
|||
protected override async Task ExecuteAsync(CancellationToken ct)
|
||||
{
|
||||
using var timer = new PeriodicTimer(TimeSpan.FromSeconds(1));
|
||||
var tasks = new List<Task>();
|
||||
|
||||
while (await timer.WaitForNextTickAsync(ct))
|
||||
{
|
||||
var guildIds = _guildData.GetGuildIds();
|
||||
|
||||
tasks.AddRange(guildIds.Select(async id =>
|
||||
foreach (var id in guildIds)
|
||||
{
|
||||
var tickResult = await TickScheduledEventsAsync(id, ct);
|
||||
_logger.LogResult(tickResult, $"Error in scheduled events update for guild {id}.");
|
||||
}));
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
tasks.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue