[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Timers, scheduling and Ruby

Vassilis Rizopoulos

11/30/2006 1:51:00 PM

Ok, since the original post migh just appear in a month's time, lets
rephrase the question:

I'm building a set of tools for build and test management (yes, yes, it
will do DamagaControl's work and yes, yes it will be released...and yes,
this is code that is used in real-life projects - it's all so close to
public alpha status).
Now, I can leave scheduling to cron (or at/schtasks), but it would be
nice to provide an interface so that scheduling can be set in the
application via some administration console.
Behind the scenes cron manipulation is too flaky for my tastes (and for
windows I would need a separate implementation).
So, is there a library that will give me timers, a nice way to configure
them and a nice event driven interface? :)
Cheers,
V.-
--
http://www.braveworl...

21 Answers

M. Edward (Ed) Borasky

11/30/2006 2:56:00 PM

0

Damphyr wrote:
> Ok, since the original post migh just appear in a month's time, lets
> rephrase the question:
You've discovered a chronosynclastic infundibulum, apparently. :)
>
> I'm building a set of tools for build and test management (yes, yes,
> it will do DamagaControl's work and yes, yes it will be released...and
> yes, this is code that is used in real-life projects - it's all so
> close to public alpha status).
> Now, I can leave scheduling to cron (or at/schtasks), but it would be
> nice to provide an interface so that scheduling can be set in the
> application via some administration console.
> Behind the scenes cron manipulation is too flaky for my tastes (and
> for windows I would need a separate implementation).
> So, is there a library that will give me timers, a nice way to
> configure them and a nice event driven interface? :)
> Cheers,
> V.-
Event Machine?

--
M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
http://borasky-research.blo...

If God had meant for carrots to be eaten cooked, He would have given rabbits fire.


James Gray

11/30/2006 3:56:00 PM

0

On Nov 30, 2006, at 7:51 AM, Damphyr wrote:

> Behind the scenes cron manipulation is too flaky for my tastes (and
> for windows I would need a separate implementation).
> So, is there a library that will give me timers, a nice way to
> configure them and a nice event driven interface? :)

I've wanted this myself. I wonder if we could get it down to Ruby
Quiz size...

James Edward Gray II

Vassilis Rizopoulos

11/30/2006 4:05:00 PM

0

M. Edward (Ed) Borasky wrote:

>> So, is there a library that will give me timers, a nice way to
>> configure them and a nice event driven interface? :)
>> Cheers,
>> V.-
> Event Machine?
I'm not sure about this. EventMachine seems geared towards networking.
I just want a class that will tick away on it's own thread and fire
events at designated time points.
My requirements include firing at intervals (every thirty minutes, every
two days), once (in thirty minutes, on 1/1/2007 at 0:00 etc.) and I
would like to have named events if possible.
Getting the events should be as simple as observing the timer.
So will anybody save me the work or do I have to code the beast?
Cheers,
V.-

--
http://www.braveworl...

Rob Sanheim

11/30/2006 5:10:00 PM

0

On 11/30/06, Damphyr <damphyr@freemail.gr> wrote:
> I'm not sure about this. EventMachine seems geared towards networking.
> I just want a class that will tick away on it's own thread and fire
> events at designated time points.
> My requirements include firing at intervals (every thirty minutes, every
> two days), once (in thirty minutes, on 1/1/2007 at 0:00 etc.) and I
> would like to have named events if possible.
> Getting the events should be as simple as observing the timer.
> So will anybody save me the work or do I have to code the beast?
> Cheers,
> V.-

I have nothing worthwhile to add, other then that I've also definitely
wanted something like this. rubyquiz?

- rob

Ara.T.Howard

11/30/2006 5:48:00 PM

0

James Gray

11/30/2006 5:56:00 PM

0

On Nov 30, 2006, at 11:47 AM, ara.t.howard@noaa.gov wrote:

> On Fri, 1 Dec 2006, James Edward Gray II wrote:
>
>> On Nov 30, 2006, at 7:51 AM, Damphyr wrote:
>>
>>> Behind the scenes cron manipulation is too flaky for my tastes
>>> (and for windows I would need a separate implementation).
>>> So, is there a library that will give me timers, a nice way to
>>> configure them and a nice event driven interface? :)
>>
>> I've wanted this myself. I wonder if we could get it down to Ruby
>> Quiz size...
>
> i'm working on a library for this now. any request?

Ara, you just plain rock.

My biggest request: a sane way (read: not-cron-like) to schedule
events. ;)

James Edward Gray II

Ara.T.Howard

11/30/2006 8:30:00 PM

0

Vassilis Rizopoulos

11/30/2006 8:39:00 PM

0

James Edward Gray II wrote:
>
> My biggest request: a sane way (read: not-cron-like) to schedule
> events. ;)
How about stealing from schtasks
(http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.msp...)?
(ducks away and hides)
It doesn't have to be so convoluted.

Define the task like this

class ScheduledTask
attr_reader :name,:schedule,:schedule_params
end

Schedule is one of :minute, :hourly, :daily, :weekly, :monthly, :yearly

then according to schedule you have different options.
Universal options:
:once to generate the event only once. It's not there, then we get repeats.
:start_time to define when to start counting. If you leave it undefined
the timer starts immediately. If you define it, it should be in the future.
interval (after x minutes/hours/days/weeks/months/years an event will be
generated. if once is defined it runs once x /whatever/ after start_time)

An option valid for weekly and monthly can be :day, where you can
specify the day of the week (1-7) or month (1-31).

Would that be simple enough?
Cheers,
V.-
--
http://www.braveworl...

Francis Cianfrocca

11/30/2006 10:26:00 PM

0

On 11/30/06, Damphyr <damphyr@freemail.gr> wrote:
> M. Edward (Ed) Borasky wrote:
>
> >> So, is there a library that will give me timers, a nice way to
> >> configure them and a nice event driven interface? :)
> >> Cheers,
> >> V.-
> > Event Machine?
> I'm not sure about this. EventMachine seems geared towards networking.
> I just want a class that will tick away on it's own thread and fire
> events at designated time points.
> My requirements include firing at intervals (every thirty minutes, every
> two days), once (in thirty minutes, on 1/1/2007 at 0:00 etc.) and I
> would like to have named events if possible.
> Getting the events should be as simple as observing the timer.
> So will anybody save me the work or do I have to code the beast?
> Cheers,
> V.-
>
> --
> http://www.braveworl...
>
>


Try this in EventMachine:

require 'rubygems'
require 'eventmachine'

EventMachine.run {
EventMachine.add_periodic_timer(60) {
# The code in this block gets executed every sixty seconds
}
EventMachine.add_periodic_timer(3600) {
# The code in this block gets executed once an hour
}
}


You can read the timer definitions out of a config file, configure
them dynamically on the fly, or build them with a GUI.

James Gray

12/1/2006 12:31:00 AM

0

On Nov 30, 2006, at 2:30 PM, ara.t.howard@noaa.gov wrote:

> On Fri, 1 Dec 2006, James Edward Gray II wrote:
>
>> My biggest request: a sane way (read: not-cron-like) to schedule
>> events. ;)
>
> how bout this as the time spec?
>
> http://runt.ruby...
>
> ??

Ah yes, I looked into Runy recently when someone use it to solve a
Ruby Quiz. Neat stuff. Plus, if we want additions we can just patch
them into Runt. I like it.

James Edward Gray II