diff options
| -rw-r--r-- | vm/dispatcher/pool.go | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/vm/dispatcher/pool.go b/vm/dispatcher/pool.go index d3f937b13..08bc1ebfa 100644 --- a/vm/dispatcher/pool.go +++ b/vm/dispatcher/pool.go @@ -127,18 +127,7 @@ func (p *Pool[T]) runInstance(ctx context.Context, inst *poolInstance[T]) { obj, err := p.creator(inst.idx) if err != nil { - select { - case p.BootErrors <- err: - return - default: - // Print some log message to make it visible. - log.Logf(0, "WARNING: boot error channel is full!") - } - select { - case p.BootErrors <- err: - case <-ctx.Done(): - // On context cancellation, no one might be listening on the channel. - } + p.reportBootError(ctx, err) return } defer obj.Close() @@ -166,6 +155,21 @@ func (p *Pool[T]) runInstance(ctx context.Context, inst *poolInstance[T]) { job(ctx, obj, inst.updateInfo) } +func (p *Pool[T]) reportBootError(ctx context.Context, err error) { + select { + case p.BootErrors <- err: + return + default: + // Print some log message to make it visible. + log.Logf(0, "WARNING: boot error channel is full!") + } + select { + case p.BootErrors <- err: + case <-ctx.Done(): + // On context cancellation, no one might be listening on the channel. + } +} + // ReserveForRun specifies the size of the sub-pool for the execution of custom runners. // The reserved instances will be booted, but the pool will not start the default runner. // To unreserve all instances, execute ReserveForRun(0). |
