mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-20 21:26:14 +08:00
Add timeout to worker goroutines when TERM signal is received
Wait for a certain amount of time to allow for worker goroutines to finish. If the goroutines don't finish with the timeout duration, processor will quit the goroutines and restore any unfinished tasks from the in_progress queue back to the default queue.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/go-redis/redis/v7"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hibiken/asynq/internal/rdb"
|
||||
)
|
||||
@@ -74,7 +75,10 @@ func TestPoller(t *testing.T) {
|
||||
}
|
||||
// initialize retry queue
|
||||
for _, st := range tc.initRetry {
|
||||
err := rdbClient.RetryLater(st.msg, st.processAt)
|
||||
err := r.ZAdd(retryQ, &redis.Z{
|
||||
Member: mustMarshal(t, st.msg),
|
||||
Score: float64(st.processAt.Unix()),
|
||||
}).Err()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user