mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 12:38:00 +00:00
Hardened background work against disconnected circuits (#937)
This commit is contained in:
1 parent
99089f853e
commit
f03c2d1c88
44 files changed
+500
-126
No files matched your search
@@ -131,7 +131,12 @@ public sealed class AIJobService(SettingsManager settingsManager, MessageBus mes
|
||||
await CheckpointChatAsync(state, force: true);
|
||||
await this.NotifyChangedAsync(state);
|
||||
|
||||
_ = Task.Factory.StartNew(async () => await this.RunChatGenerationAsync(state), TaskCreationOptions.LongRunning);
|
||||
//
|
||||
// Unwrap matters here: StartNew with an async delegate hands back a task which completes as soon
|
||||
// as the generation started, wrapping the task which does the actual work. Watching the outer one
|
||||
// would tell us nothing about how the generation itself ended.
|
||||
//
|
||||
Task.Factory.StartNew(async () => await this.RunChatGenerationAsync(state), TaskCreationOptions.LongRunning).Unwrap().Observe($"{nameof(AIJobService)}: running a chat generation");
|
||||
return state.Snapshot;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user