Keep track of running jobs

41 views
Skip to first unread message

Louis Coilliot

unread,
Dec 19, 2011, 12:27:11 PM12/19/11
to Rufus Ruby
Hello,

when 'in' or 'at' jobs have been triggered, they are no more in the
scheduler.all_jobs list.

But I need to keep track of running jobs.

I got some clues on this on IRC thanks to jmettraux, and I came up
with a one line patch on lib/rufus/sc/jobs.rb :

--- jobs.rb 2011-12-19 18:09:40.661879170 +0100
+++ jobs-new.rb 2011-12-19 18:09:05.430878139 +0100
@@ -177,6 +177,7 @@
# (Only jobs know about this method of the scheduler)

job_thread = Thread.current
+ job_thread['jid'] = @params[:tags]
job_thread[
"rufus_scheduler__trigger_thread__#{@scheduler.object_id}"
] = true

So running threads can be tagged like jobs.

Then I can identify my threads with :

Thread.list.each { |th| puts th['jid'] }

So I have 2 questions :
- is it clean (I am very new to rufus-scheduler and may be I'm
naive) ?
- could you consider having it (or a better approach) mainstream ?

Let me know, thanks in advance.

Louis Coilliot


John Mettraux

unread,
Dec 19, 2011, 8:56:05 PM12/19/11
to rufus...@googlegroups.com

On Mon, Dec 19, 2011 at 09:27:11AM -0800, Louis Coilliot wrote:
>
> - could you consider having it (or a better approach) mainstream ?

Hello Louis,

after considering your patch I noticed that I had already implemented that
thing:

https://github.com/jmettraux/rufus-scheduler/blob/d4c1b2d9d68d42c75c95622f3745ac7fca60e60e/lib/rufus/sc/scheduler.rb#L310-318

So I decided to 'upgrade' it a bit and I added a Scheduler#running_jobs
method:

https://github.com/jmettraux/rufus-scheduler/commit/abc192e1f48c87191242be90cc1f10def73760f4

I hope it will help, sorry not to have realized immediately.

Please tell me if you need a release of the gem that includes this new
feature.


Thanks and best regards,

--
John Mettraux - http://lambda.io/processi

Louis Coilliot

unread,
Dec 20, 2011, 4:30:36 AM12/20/11
to rufus...@googlegroups.com
Hello, I tested it and that's very fine, thanks.

I can easily create an external find_by_tag method on it.

Yes, it would be great to have a new gem with it, if that's not much
work for you.

It would definitely simplify my docs and procedures.

Louis Coilliot

2011/12/20 John Mettraux <jmet...@gmail.com>:

> --
> you received this message because you are subscribed to the "rufus ruby" group.
> to post : send email to rufus...@googlegroups.com
> to unsubscribe : send email to rufus-ruby+...@googlegroups.com
> more options : http://groups.google.com/group/rufus-ruby?hl=en

John Mettraux

unread,
Dec 20, 2011, 4:45:55 AM12/20/11
to rufus...@googlegroups.com

On Tue, Dec 20, 2011 at 10:30:36AM +0100, Louis Coilliot wrote:
>
> Yes, it would be great to have a new gem with it, if that's not much
> work for you.
>
> It would definitely simplify my docs and procedures.

Hello,

rufus-scheduler 2.0.15 is out.


Cheers,

John Mettraux

unread,
Dec 21, 2011, 8:25:43 PM12/21/11
to rufus...@googlegroups.com
2011/12/20 Louis Coilliot <louis.c...@think.fr>:
> Thanks for the quick actions !

Hello Louis,

maybe this can help with EmScheduler#running_jobs:

https://github.com/jmettraux/rufus-scheduler/commit/644dbc74f3a5fd0387a39a10abad63ba11feb1b4


Cheers,

John

Reply all
Reply to author
Forward
0 new messages