mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-06 10:42:12 -04:00
fix(engine): discard cancelled pipeline results from uncooperative engines
This commit is contained in:
1 parent
c914d2bbd9
commit
7aeb636ca2
2 files changed
+17
No files matched your search
@@ -101,6 +101,21 @@ public class NestPipelineTests
|
||||
Assert.Contains("Default", error.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CancellationDuringSolveDiscardsEvenAnEngineThatReturnsNormally()
|
||||
{
|
||||
using var cts = new CancellationTokenSource();
|
||||
var engine = new StubEngine(job =>
|
||||
{
|
||||
cts.Cancel();
|
||||
return OnePlate(job, new NestJobPlacement(job.Parts[0].Id, 0, 1, 1, 0));
|
||||
});
|
||||
|
||||
Assert.ThrowsAny<OperationCanceledException>(() =>
|
||||
NestPipeline.Run(engine, "IgnoresStop", Request("IgnoresStop", Item("bracket", 1)), null, cts.Token)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CancellationPropagatesWithoutAResult()
|
||||
{
|
||||
|
||||
@@ -115,6 +115,7 @@ public static class NestPipeline
|
||||
engine.Solve(job, progress, token)
|
||||
?? throw new InvalidOperationException($"Engine '{engineName}' returned no result.");
|
||||
var solveTime = clock.Elapsed;
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
clock.Restart();
|
||||
var violations = Validate(job, raw, drawingsByPartId);
|
||||
@@ -128,6 +129,7 @@ public static class NestPipeline
|
||||
))
|
||||
.ToList();
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
return new NestPipelineResult(
|
||||
engineName,
|
||||
job,
|
||||
|
||||
Reference in new issue
Block a user