Skip to content

Commit

Permalink
fix: set different timeout for rank
Browse files Browse the repository at this point in the history
  • Loading branch information
Rorical committed Apr 21, 2023
1 parent d72222c commit 5051c37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions common/database/tasktracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func (tl *TaskListener) CloseChan() {
tl.redis.Close()
}

func (tl *TaskListener) WaitFor(ctx context.Context, tid string) error {
timeout := time.After(1 * time.Minute)
func (tl *TaskListener) WaitFor(ctx context.Context, tid string, delay time.Duration) error {
timeout := time.After(delay)
signal := make(chan error, 1)
go func() {
tl.cond.L.Lock()
Expand Down
11 changes: 6 additions & 5 deletions modules/responser/task/gens.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package task
import (
"context"
"fmt"
"time"

"github.com/ShugetsuSoft/pixivel-back/common/models"
"github.com/ShugetsuSoft/pixivel-back/common/utils"
Expand All @@ -28,7 +29,7 @@ func (gen *TaskGenerator) IllustDetailTask(ctx context.Context, id uint64) error
return err
}
}
err = gen.tracerlistener.WaitFor(ctx, tid)
err = gen.tracerlistener.WaitFor(ctx, tid, time.Minute)
if err != nil {
gen.tracer.RemoveTaskGroup(tid)
return err
Expand All @@ -55,7 +56,7 @@ func (gen *TaskGenerator) UgoiraDetailTask(ctx context.Context, id uint64) error
return err
}
}
err = gen.tracerlistener.WaitFor(ctx, tid)
err = gen.tracerlistener.WaitFor(ctx, tid, time.Minute)
if err != nil {
gen.tracer.RemoveTaskGroup(tid)
return err
Expand All @@ -82,7 +83,7 @@ func (gen *TaskGenerator) UserDetailTask(ctx context.Context, id uint64) error {
return err
}
}
err = gen.tracerlistener.WaitFor(ctx, tid)
err = gen.tracerlistener.WaitFor(ctx, tid, time.Minute)
if err != nil {
gen.tracer.RemoveTaskGroup(tid)
return err
Expand All @@ -109,7 +110,7 @@ func (gen *TaskGenerator) UserIllustsTask(ctx context.Context, id uint64) error
return err
}
}
err = gen.tracerlistener.WaitFor(ctx, tid)
err = gen.tracerlistener.WaitFor(ctx, tid, time.Minute)
if err != nil {
gen.tracer.RemoveTaskGroup(tid)
return err
Expand All @@ -135,7 +136,7 @@ func (gen *TaskGenerator) RankInitTask(ctx context.Context, mode string, date st
return err
}
}
err = gen.tracerlistener.WaitFor(ctx, tid)
err = gen.tracerlistener.WaitFor(ctx, tid, 5*time.Minute)
if err != nil {
gen.tracer.RemoveTaskGroup(tid)
return err
Expand Down

0 comments on commit 5051c37

Please sign in to comment.