Skip to content

Commit 5ed2332

Browse files
authored
Always check for dynamic concurrency environment when setting worker count (#8570)
1 parent 09701de commit 5ed2332

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/WebJobs.Script/Workers/Rpc/FunctionRegistration/RpcFunctionInvocationDispatcher.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ private async Task<int> GetMaxProcessCount()
117117
return MultiLanguageDefaultProcessCount;
118118
}
119119

120-
if (_workerConcurrencyOptions != null && !string.IsNullOrEmpty(_workerRuntime))
120+
if (!string.IsNullOrEmpty(_workerRuntime))
121121
{
122122
var workerConfig = _workerConfigs.Where(c => c.Description.Language.Equals(_workerRuntime, StringComparison.InvariantCultureIgnoreCase))
123-
.FirstOrDefault();
123+
.FirstOrDefault();
124124
if (workerConfig != null)
125125
{
126-
return _environment.IsWorkerDynamicConcurrencyEnabled() ? _workerConcurrencyOptions.Value.MaxWorkerCount : workerConfig.CountOptions.ProcessCount;
126+
return workerConfig.CountOptions.ProcessCount;
127127
}
128128
}
129129

@@ -490,7 +490,7 @@ internal async Task<IEnumerable<IRpcWorkerChannel>> GetInitializedWorkerChannels
490490
IEnumerable<IRpcWorkerChannel> workerChannels = await GetAllWorkerChannelsAsync(language);
491491
IEnumerable<IRpcWorkerChannel> initializedWorkers = workerChannels.Where(ch => ch.IsChannelReadyForInvocations());
492492

493-
int workerCount = await _maxProcessCount.Value;
493+
int workerCount = _environment.IsWorkerDynamicConcurrencyEnabled() ? _workerConcurrencyOptions.Value.MaxWorkerCount : await _maxProcessCount.Value;
494494
if (initializedWorkers.Count() > workerCount)
495495
{
496496
throw new InvalidOperationException($"Number of initialized language workers exceeded:{initializedWorkers.Count()} exceeded maxProcessCount: {workerCount}");

0 commit comments

Comments
 (0)