Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: taskHandler dispose in PostProcessor #608

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions Common/src/Pollster/PostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Threading.Tasks;

using ArmoniK.Api.Common.Utils;
using ArmoniK.Utils;

using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
Expand All @@ -31,7 +32,6 @@ public class PostProcessor : BackgroundService
{
private readonly ILogger<PostProcessor> logger_;
private readonly PostProcessingTaskQueue postProcessingTaskQueue_;
public string CurrentTask = string.Empty;

public PostProcessor(PostProcessingTaskQueue postProcessingTaskQueue,
ILogger<PostProcessor> logger)
Expand All @@ -46,13 +46,13 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var taskHandler = await postProcessingTaskQueue_.ReadAsync(stoppingToken)
.ConfigureAwait(false);
await using var taskHandlerDispose = new Deferrer(taskHandler);

var taskInfo = taskHandler.GetAcquiredTaskInfo();

using var _ = logger_.BeginPropertyScope(("messageHandler", taskInfo.MessageId),
("taskId", taskInfo.TaskId),
("sessionId", taskInfo.SessionId));
CurrentTask = taskInfo.TaskId;

try
{
Expand All @@ -66,12 +66,6 @@ await taskHandler.PostProcessing()
postProcessingTaskQueue_.AddException(ExceptionDispatchInfo.Capture(e)
.SourceException);
}
finally
{
await taskHandler.DisposeAsync()
.ConfigureAwait(false);
CurrentTask = string.Empty;
}
}

logger_.LogWarning("End of task post processor; no more tasks will be finalized");
Expand Down
Loading