Skip to content

Commit b1c5107

Browse files
authored
Update placeholder channel check for Python (#7608)
1 parent d6eb337 commit b1c5107

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ public async Task InitializeAsync(IEnumerable<FunctionMetadata> functions, Cance
187187
{
188188
cancellationToken.ThrowIfCancellationRequested();
189189

190-
if (_environment.IsPlaceholderModeEnabled())
190+
var placeholderModeEnabled = _environment.IsPlaceholderModeEnabled();
191+
_logger.LogDebug($"Placeholder mode is enabled: {placeholderModeEnabled}");
192+
193+
if (placeholderModeEnabled)
191194
{
192195
return;
193196
}

src/WebJobs.Script/Workers/Rpc/RpcInitializationService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,14 @@ internal bool ShouldStartStandbyPlaceholderChannels()
189189
internal bool ShouldStartAsPlaceholderPool()
190190
{
191191
// We are in placeholder mode but a worker runtime IS set
192-
return _environment.IsPlaceholderModeEnabled()
192+
_logger.LogDebug($"Placeholder mode enabled is {_environment.IsPlaceholderModeEnabled()} for worker {_workerRuntime}");
193+
194+
var ret = _environment.IsPlaceholderModeEnabled()
193195
&& !string.IsNullOrEmpty(_workerRuntime)
194196
&& _placeholderPoolRuntimesAllowList.Contains(_workerRuntime, StringComparer.OrdinalIgnoreCase);
197+
198+
_logger.LogDebug($"Starting language worker in placeholder mode: {ret}");
199+
return ret;
195200
}
196201

197202
// To help with unit tests

src/WebJobs.Script/Workers/Rpc/WebHostRpcWorkerChannelManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ private bool UsePlaceholderChannel(string workerRuntime)
145145
// Also cannot use placeholder worker that is targeting ~3 but has backwards compatibility with V2 enabled
146146
// TODO: Remove special casing when resolving https://github.com/Azure/azure-functions-host/issues/4534
147147
if (string.Equals(workerRuntime, RpcWorkerConstants.NodeLanguageWorkerName, StringComparison.OrdinalIgnoreCase)
148-
|| string.Equals(workerRuntime, RpcWorkerConstants.PowerShellLanguageWorkerName, StringComparison.OrdinalIgnoreCase))
148+
|| string.Equals(workerRuntime, RpcWorkerConstants.PowerShellLanguageWorkerName, StringComparison.OrdinalIgnoreCase)
149+
|| string.Equals(workerRuntime, RpcWorkerConstants.PythonLanguageWorkerName, StringComparison.OrdinalIgnoreCase))
149150
{
150151
// Use if readonly and not v2 compatible on ~3 extension
151152
return _applicationHostOptions.CurrentValue.IsFileSystemReadOnly && !_environment.IsV2CompatibileOnV3Extension();

test/WebJobs.Script.Tests/Workers/Rpc/WebHostRpcWorkerChannelManagerTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ public async Task ShutdownStandyChannels_WorkerRuntime_Node_Set()
167167
[InlineData("Node", RpcWorkerConstants.NodeLanguageWorkerName)]
168168
[InlineData("PowerShell", RpcWorkerConstants.PowerShellLanguageWorkerName)]
169169
[InlineData("pOwerShell", RpcWorkerConstants.PowerShellLanguageWorkerName)]
170+
[InlineData("python", RpcWorkerConstants.PythonLanguageWorkerName)]
171+
[InlineData("pythoN", RpcWorkerConstants.PythonLanguageWorkerName)]
170172
public async Task SpecializeAsync_ReadOnly_KeepsProcessAlive(string runtime, string languageWorkerName)
171173
{
172174
var testMetricsLogger = new TestMetricsLogger();
@@ -258,6 +260,7 @@ await TestHelpers.Await(() =>
258260
[Theory]
259261
[InlineData(RpcWorkerConstants.NodeLanguageWorkerName)]
260262
[InlineData(RpcWorkerConstants.PowerShellLanguageWorkerName)]
263+
[InlineData(RpcWorkerConstants.PythonLanguageWorkerName)]
261264
public async Task SpecializeAsync_NotReadOnly_KillsProcess(string languageWorkerName)
262265
{
263266
var testMetricsLogger = new TestMetricsLogger();
@@ -316,6 +319,7 @@ public async Task SpecializeAsync_LanguageWorkerArguments_KillsProcess(string la
316319
[Theory]
317320
[InlineData(RpcWorkerConstants.NodeLanguageWorkerName)]
318321
[InlineData(RpcWorkerConstants.PowerShellLanguageWorkerName)]
322+
[InlineData(RpcWorkerConstants.PythonLanguageWorkerName)]
319323
public async Task SpecializeAsync_Node_V2CompatibilityWithV3Extension_KillsProcess(string languageWorkerName)
320324
{
321325
var testMetricsLogger = new TestMetricsLogger();

0 commit comments

Comments
 (0)