Commit d875e99e authored by Jesse Gross's avatar Jesse Gross Committed by Jesse Gross
Browse files

runner.go: Propagate panics back to the user.

This is a partial revert of 8a35bb92
"runner.go: Increase survivability of main processing loop", removing
the panic handler.

Although we want to avoid errors taking down the runner, we also
should make the user aware of problems when they happen. In the
future, we can restructure things so both parts are true.
parent 8a35bb92
...@@ -14,7 +14,6 @@ import ( ...@@ -14,7 +14,6 @@ import (
"path/filepath" "path/filepath"
"regexp" "regexp"
"runtime" "runtime"
"runtime/debug"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
...@@ -340,15 +339,6 @@ func (s *Server) run(ctx context.Context) { ...@@ -340,15 +339,6 @@ func (s *Server) run(ctx context.Context) {
// it should only be responsible for accepting tokens or embeddings and // it should only be responsible for accepting tokens or embeddings and
// processing batches as fast as possible // processing batches as fast as possible
func (s *Server) processBatch(tokenBatch *llama.Batch, embedBatch *llama.Batch) { func (s *Server) processBatch(tokenBatch *llama.Batch, embedBatch *llama.Batch) {
// Try to keep going even if we hit a panic so that corner cases don't take the whole
// runner down. In most cases, this will result in dropping the tokens that we are currently
// processing and then continuing with what is remaining.
defer func() {
if err := recover(); err != nil {
slog.Error("error while processing batch", "error", err, "stack", debug.Stack())
}
}()
s.mu.Lock() s.mu.Lock()
for s.allNil() { for s.allNil() {
s.cond.Wait() // Wait until an item is added s.cond.Wait() // Wait until an item is added
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment