From 5dcb1199c71aff4a722bdc3e40ed360c3b1d0a5b Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Fri, 17 Mar 2023 16:31:52 -0400 Subject: [PATCH] limit parallel postgres requests --- .../Processors/RetrieveFollowersProcessor.cs | 7 +++++++ .../BirdsiteLive.DAL.Postgres.csproj | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs index a34adfb..88a56a8 100644 --- a/src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs +++ b/src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; using BirdsiteLive.DAL.Contracts; @@ -29,7 +30,13 @@ namespace BirdsiteLive.Pipeline.Processors user.Followers = followers; }); todo.Add(t); + + if (todo.Count(x => !x.IsCompleted) >= 25) + { + await Task.WhenAny(todo); + } } + await Task.WhenAll(todo); return userWithTweetsToSyncs; diff --git a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/BirdsiteLive.DAL.Postgres.csproj b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/BirdsiteLive.DAL.Postgres.csproj index 84a3210..c4c49db 100644 --- a/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/BirdsiteLive.DAL.Postgres.csproj +++ b/src/DataAccessLayers/BirdsiteLive.DAL.Postgres/BirdsiteLive.DAL.Postgres.csproj @@ -6,7 +6,7 @@ - +