do not use async for queue processing
This commit is contained in:
@@ -116,14 +116,14 @@ public class RequestQueueService : IHostedService
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DequeueIntoSlotAsync(UserRequest userRequest, int slot)
|
private void DequeueIntoSlot(UserRequest userRequest, int slot)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Dequeueing {req} into {i}: {user} with {file}", userRequest.RequestId, slot, userRequest.User, string.Join(", ", userRequest.FileIds));
|
_logger.LogDebug("Dequeueing {req} into {i}: {user} with {file}", userRequest.RequestId, slot, userRequest.User, string.Join(", ", userRequest.FileIds));
|
||||||
_userQueueRequests[slot] = new(userRequest, DateTime.UtcNow.AddSeconds(_queueExpirationSeconds));
|
_userQueueRequests[slot] = new(userRequest, DateTime.UtcNow.AddSeconds(_queueExpirationSeconds));
|
||||||
await _hubContext.Clients.User(userRequest.User).SendAsync(nameof(IMareHub.Client_DownloadReady), userRequest.RequestId).ConfigureAwait(false);
|
_ = _hubContext.Clients.User(userRequest.User).SendAsync(nameof(IMareHub.Client_DownloadReady), userRequest.RequestId).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ProcessQueue(object src, ElapsedEventArgs e)
|
private void ProcessQueue(object src, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Periodic Processing Queue Start");
|
_logger.LogDebug("Periodic Processing Queue Start");
|
||||||
_metrics.SetGaugeTo(MetricsAPI.GaugeQueueFree, _userQueueRequests.Count(c => c == null));
|
_metrics.SetGaugeTo(MetricsAPI.GaugeQueueFree, _userQueueRequests.Count(c => c == null));
|
||||||
@@ -140,7 +140,7 @@ public class RequestQueueService : IHostedService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _queueProcessingSemaphore.WaitAsync().ConfigureAwait(false);
|
_queueProcessingSemaphore.Wait();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -171,7 +171,7 @@ public class RequestQueueService : IHostedService
|
|||||||
{
|
{
|
||||||
if (prioRequest.IsCancelled) continue;
|
if (prioRequest.IsCancelled) continue;
|
||||||
|
|
||||||
await DequeueIntoSlotAsync(prioRequest, i).ConfigureAwait(false);
|
DequeueIntoSlot(prioRequest, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ public class RequestQueueService : IHostedService
|
|||||||
{
|
{
|
||||||
if (request.IsCancelled) continue;
|
if (request.IsCancelled) continue;
|
||||||
|
|
||||||
await DequeueIntoSlotAsync(request, i).ConfigureAwait(false);
|
DequeueIntoSlot(request, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user