Skip to content

Commit c8211dd

Browse files
committed
Suppressing execution context flow on create/update/delete
1 parent 5652e92 commit c8211dd

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/WebJobs.Script.WebHost/Controllers/FunctionsController.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public async Task<IActionResult> CreateOrUpdate(string name, [FromBody] Function
7878
{
7979
(success, configChanged, functionMetadataResponse) = await _functionsManager.CreateOrUpdate(name, functionMetadata, Request);
8080
}
81-
await fileMonitoringService.ScheduleRestartAsync(false);
81+
await ScheduleRestartAsync(fileMonitoringService);
8282

8383
if (success)
8484
{
@@ -175,11 +175,11 @@ public async Task<IActionResult> Delete(string name, [FromServices] IFileMonitor
175175

176176
bool deleted;
177177
string error;
178-
using (fileMonitoringService?.SuspendRestart())
178+
using (fileMonitoringService.SuspendRestart())
179179
{
180180
(deleted, error) = await _functionsManager.TryDeleteFunction(function);
181181
}
182-
await fileMonitoringService?.ScheduleRestartAsync(false);
182+
await ScheduleRestartAsync(fileMonitoringService);
183183

184184
if (deleted)
185185
{
@@ -220,5 +220,15 @@ public IActionResult Download([FromServices] IOptions<ScriptApplicationHostOptio
220220
FileDownloadName = (System.Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME") ?? "functions") + ".zip"
221221
};
222222
}
223+
224+
private async Task ScheduleRestartAsync(IFileMonitoringService fileMonitoringService)
225+
{
226+
Task restartTask = null;
227+
using (System.Threading.ExecutionContext.SuppressFlow())
228+
{
229+
restartTask = fileMonitoringService.ScheduleRestartAsync(false);
230+
}
231+
await restartTask;
232+
}
223233
}
224234
}

0 commit comments

Comments
 (0)