gpt4 book ai didi

ruby-on-rails - 将 Sucker Punch 与 Active Job 一起使用,有没有办法取消排队的作业?

转载 作者:行者123 更新时间:2023-12-05 07:50:18 25 4
gpt4 key购买 nike

所以我有MyJob.perform_in(60, @user),这将在 60 秒内完成我的工作。

如果这行代码再次运行并替换队列中的代码,我想取消此作业。

我没有运气研究。

最佳答案

获取与 SuckerPunch 作业相关的统计数据

[14] pry(main)> SuckerPunch::Queue.stats
{
"CreateVVLinkJob" => {
"workers" => {
"total" => 1,
"busy" => 0,
"idle" => 1
},
"jobs" => {
"processed" => 1,
"failed" => 0,
"enqueued" => 0
}
}
}

并清除以前的作业

[24] pry(main)> SuckerPunch::Queue.clear
[
[0] #<SuckerPunch::Queue:0x0000000b150da0 @__lock__=#<Mutex:0x0000000b150d50>, @__condition__=#<Thread::ConditionVariable:0x0000000b150d28>, @running=false, @name="CreateVVLinkJob", @pool=#<Concurrent::ThreadPoolExecutor:0x0000000b146ad0 @__lock__=#<Mutex:0x0000000b1469e0>, @__condition__=#<Thread::ConditionVariable:0x0000000b1469b8>, @min_length=2, @max_length=2, @idletime=60, @max_queue=0, @fallback_policy=:abort, @auto_terminate=false, @pool=[], @ready=[], @queue=[], @scheduled_task_count=1, @completed_task_count=1, @largest_length=1, @ruby_pid=22314, @gc_interval=30, @next_gc_time=25973.834404648, @StopEvent=#<Concurrent::Event:0x0000000b1468c8 @__lock__=#<Mutex:0x0000000b146878>, @__condition__=#<Thread::ConditionVariable:0x0000000b146850>, @set=true, @iteration=0>, @StoppedEvent=#<Concurrent::Event:0x0000000b1467d8 @__lock__=#<Mutex:0x0000000b146788>, @__condition__=#<Thread::ConditionVariable:0x0000000b146760>, @set=true, @iteration=0>>>
]

希望有用!

关于ruby-on-rails - 将 Sucker Punch 与 Active Job 一起使用,有没有办法取消排队的作业?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36315804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com