Comments (14)
Is there some kind of fallback scenario where that value might be true instead of the job instance?
Hello,
It's not a fallback, it's a temporary true
value, to pre-reserve before assignation. IIRC.
https://github.com/jmettraux/rufus-scheduler/blob/master/lib/rufus/scheduler/jobs_core.rb#L311-L312
from rufus-scheduler.
"losing data" sounds scary.
There is also the case where the thread use by the job just ended and it pops in your loop because when the .threads(:active)
array was established it serviced a job, but when you consider it, it might have ended. I would do something like
schedule.work_threads(:active).each do |t|
i = t[:rufus_scheduler_job].identifier rescue nil
thread_usage[i] += 1 if i
end
That should cover the nil
and the true
extra cases.
from rufus-scheduler.
Job#name
rufus-scheduler/spec/job_spec.rb
Lines 389 to 397 in 64591be
from rufus-scheduler.
Hello,
I have the impression the hacks are better at the level of your ruby-clock gem.
Regarding the name, how about
class Rufus::Scheduler::Job
def full_name
[ name, source_location.map(&:to_s).join(':') ].join(' ')
end
end
which returns something like "alice /home/jmettraux/w/rufus-scheduler/spec/job_spec.rb:408"
?
It uses the #source_location
method I added to Job
.
Best regards.
from rufus-scheduler.
wow cool! thanks!
do you know if there's a way to access the job from schedule.work_threads(:active).first
?
from rufus-scheduler.
Hello,
yes, you can do
scheduler.work_threads(:active).each_with_index do |t, i|
puts "#{i}. work thread #{t.id} is active for job #{t[:rufus_scheduler_job].source_location}"
end
Is that sufficient?
from rufus-scheduler.
this is perfect - this code gives me exactly what i wanted
job_code = schedule.work_threads(:active).map do |t|
t[:rufus_scheduler_job].handler.source.split("\n")[1].strip
end
from rufus-scheduler.
OK, give me one or two days to release with Job#source_location
, then I will close this issue.
Best regards.
from rufus-scheduler.
Thanks, for now I don't need it for what I'm working on, so no time pressure here. I'll let you know what I come up with.
from rufus-scheduler.
Okay, I've made Rufus::Scheduler::Job#identifier
jjb/ruby-clock#2
I'm going to implement this at work first to see if I want to update anything, so it will get merged and released in the next few days. Any feedback welcome!
edit: I did actually end up depending on the new source_location feature!
from rufus-scheduler.
just got a confusing error message from this code:
schedule.work_threads(:active).each do |t|
thread_usage[t[:rufus_scheduler_job].identifier] += 1
end
undefined method `identifier' for true:TrueClass
it happened exactly once when my clock process started. Now that loop, which runs every 10 seconds, seems to be happy and functional.
Is there some kind of fallback scenario where that value might be true
instead of the job instance?
from rufus-scheduler.
Gotcha, thanks! So it's only when the thread is starting up. so i think i can safely just next
along when i see that and not risk losing any data
from rufus-scheduler.
Thanks!
from rufus-scheduler.
great! and thanks for the extra info about missing jobs
from rufus-scheduler.
Related Issues (20)
- How to schedule a job and stop after some time? HOT 3
- scheduler.every vs scheduler.cron HOT 14
- Please allow arbitrary content-type headers HOT 1
- Rufus not triggering when running Puma as a daemon (Rufus 3.7, Puma 5.2.1) HOT 6
- Getting time when cron job is invoked HOT 3
- A better way to check if Rails was run from console HOT 16
- Why does `.at` execute the job immediately but `.cron` does not? HOT 1
- Is there a way to access when a job "would have" run HOT 11
- Rails reloader HOT 3
- [Question] Does scheduler runs at the specified time irrespective of day light savings for the provided timezone? HOT 5
- Frequently failing Rufus::Scheduler#around_trigger does not block test HOT 7
- Rufus and Database Connections HOT 4
- Scheduling thread can die silently HOT 7
- Potential bug in handling threads on failure HOT 6
- When I add a cron job with a time in the past, I get a scheduled job in the future HOT 1
- past date/time jobs are run immediately HOT 6
- schedule_at("Wed at 2pm") should always be the next available Wed at 2pm HOT 2
- Time zone not passed to worker threads HOT 2
- discard_past doesn't seem to be working for "every" jobs with max_work_threads HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rufus-scheduler.