fix(worker): Blender jobs always failed with "Collection was modified"
LogTail was read by the progress loop while the output pumps appended to it. Blender rewrites its status line many times a second, so the first progress report of every job threw; aerender hit the same race only rarely. LogTail now locks internally. The exception also escaped BlenderRunner without ending the process, leaving blender.exe rendering unsupervised on the node on every failed attempt. Any unexpected exception in the monitor loop now kills the process tree. Bump worker to 1.6.2. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -280,11 +280,19 @@ public sealed class AerenderRunner
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Ring buffer of the last N output lines (§5.3 logTail).</summary>
|
||||
/// <summary>
|
||||
/// Ring buffer of the last N output lines (§5.3 logTail).
|
||||
///
|
||||
/// Thread-safe: output readers add lines while the progress loop reads the
|
||||
/// tail for its report. Unsynchronised, ToString enumerates the queue while a
|
||||
/// reader enqueues and throws "Collection was modified" — Blender, which
|
||||
/// writes a status line many times a second, hit this on every job.
|
||||
/// </summary>
|
||||
public sealed class LogTail
|
||||
{
|
||||
private readonly Queue<string> _lines;
|
||||
private readonly int _capacity;
|
||||
private readonly object _gate = new();
|
||||
|
||||
public LogTail(int capacity)
|
||||
{
|
||||
@@ -294,9 +302,15 @@ public sealed class LogTail
|
||||
|
||||
public void Add(string line)
|
||||
{
|
||||
_lines.Enqueue(line);
|
||||
while (_lines.Count > _capacity) _lines.Dequeue();
|
||||
lock (_gate)
|
||||
{
|
||||
_lines.Enqueue(line);
|
||||
while (_lines.Count > _capacity) _lines.Dequeue();
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() => string.Join('\n', _lines);
|
||||
public override string ToString()
|
||||
{
|
||||
lock (_gate) return string.Join('\n', _lines);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user