fix: try to fix database connections not being closed sometimes
This commit is contained in:
parent
1a63540f89
commit
db3e6fa7b0
2 changed files with 21 additions and 8 deletions
|
|
@ -25,7 +25,8 @@ public class TimeoutService(
|
|||
_logger.Information("Populating timeout service with existing database timeouts");
|
||||
|
||||
await using var scope = serviceProvider.CreateAsyncScope();
|
||||
var timeoutRepository = scope.ServiceProvider.GetRequiredService<TimeoutRepository>();
|
||||
await using var timeoutRepository =
|
||||
scope.ServiceProvider.GetRequiredService<TimeoutRepository>();
|
||||
|
||||
var timeouts = await timeoutRepository.GetAllAsync();
|
||||
foreach (var timeout in timeouts)
|
||||
|
|
@ -53,8 +54,10 @@ public class TimeoutService(
|
|||
_logger.Information("Sending timeout log for {TimeoutId}", timeoutId);
|
||||
|
||||
await using var scope = serviceProvider.CreateAsyncScope();
|
||||
var guildRepository = scope.ServiceProvider.GetRequiredService<GuildRepository>();
|
||||
var timeoutRepository = scope.ServiceProvider.GetRequiredService<TimeoutRepository>();
|
||||
await using var guildRepository =
|
||||
scope.ServiceProvider.GetRequiredService<GuildRepository>();
|
||||
await using var timeoutRepository =
|
||||
scope.ServiceProvider.GetRequiredService<TimeoutRepository>();
|
||||
|
||||
var timeout = await timeoutRepository.RemoveAsync(timeoutId);
|
||||
if (timeout == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue