We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I submit task successfully, but the task is not executed.
Init pool:
func InitPool() { var err error GoPool, err = ants.NewPool(11, ants.WithPanicHandler( func(i interface{}) { stack := string(debug.Stack()) llog.Errorf(context.Background(), "[GoPool] panic: %v | Stack Trace:%s", i, stack) }, )) if err != nil { llog.Fatalf(context.Background(), "init GoPool failed: %s", err) } }
submit task
func run() { ctx := context.TODO() task, err := db.GetReadyTasks(ctx) if err != nil { llog.Errorf(ctx, "[TriedDrivingDetectCron] get ready tasks failed: %v", err) } for _, task := range task { err = db.DelDataProcessTaskByTaskKey(ctx, task.TaskKey, db.DataProcessTaskTypeTiredDriving) if err != nil { llog.Errorf(ctx, "[TriedDrivingDetectCron] del task failed task: %+v err: %v", task, err) continue } llog.WithContext(ctx).Infof("[TriedDrivingDetectCron] start detect task. TaskKey=%s, TaskType=%d", task.TaskKey, task.TaskType) err = pool.GoPool.Submit(func() { llog.WithContext(ctx).Debugf("[TriedDrivingDetectCron] start detect goroutine. taskKey=%s", task.TaskKey) _, err := TiredDrivingDetect(ctx, task) if err != nil && !errors.Is(err, ErrOrderIsNotOnGoing) { llog.Errorf(ctx, "[TriedDrivingDetectCron] detect failed: %v. taskKey=%s", err, task.TaskKey) } }) if err != nil { llog.Errorf(ctx, "[TriedDrivingDetectCron] submit task failed: %v. taskKey=%s", err, task.TaskKey) } else { llog.WithContext(ctx).Debugf("[TriedDrivingDetectCron] end detect task. TaskKey=%s, TaskType=%d", task.TaskKey, task.TaskType) } } } func TiredDrivingDetect(ctx context.Context, task db.DataProcessTask) (result DetectCounter, err error) { llog.WithContext(ctx).Debugf("[tiredDrivingDetect] get task: %+v", task) var detail TiredDrivingTaskDetail err = jsoniter.UnmarshalFromString(task.Detail, &detail) if err != nil { llog.Errorf(ctx, "[TriedDrivingDetectCron] parse detail failed: %v. detail=%s", err, task.Detail) return } ... }
get log like this:
v1
v1.3.0
Linux
Linux 5.10.134-17.3.al8.x86_64 x86_64
go1.20.13
It is mentioned above
No response
Steps to reproduce the behavior:
It can reproduce with the latest release
The text was updated successfully, but these errors were encountered:
Please upgrade to v2, v1 is no longer maintained.
Sorry, something went wrong.
I have try v2, it has the same issue.
What specific v2 version have you tried?
Your example involved too much business logic, please provide a reproducer without these business logic.
panjf2000
No branches or pull requests
Actions I've taken before I'm here
What happened?
I submit task successfully, but the task is not executed.
Init pool:
submit task
get log like this:
Major version of ants
v1
Specific version of ants
v1.3.0
Operating system
Linux
OS version
Linux 5.10.134-17.3.al8.x86_64 x86_64
Go version
go1.20.13
Relevant log output
Code snippets (optional)
No response
How to Reproduce
Steps to reproduce the behavior:
Does this issue reproduce with the latest release?
It can reproduce with the latest release
The text was updated successfully, but these errors were encountered: