scheduler : substantial rewrite

0 views
Skip to first unread message

John Mettraux

unread,
Jan 7, 2008, 4:50:07 AM1/7/08
to openwfe...@googlegroups.com
Hi guys,

I know some of you here are using the openwferu-scheduler [gem], so
you might be interested by a change I just made.

I came across this blog post :
http://rubyisgrate.blogspot.com/2008/01/hoppy-next-year.html

It details an issue with the scheduler and the change fixed it.

The cause was a bit too much of synchronization (using Monitor). I
discarded the monitor in the scheduler and am I now using two queues
(schedule/unschedule).
http://fisheye3.cenqua.com/browse/openwferu/trunk/openwfe-ruby/lib/openwfe/util/scheduler.rb?r1=1424&r2=1425

I battled the test cases for a while, they are now all running successfully.

Are they any visible change ?

Not really, the interface is the same (method names everything).
Except for the unschedule methods which now don't return anything
(they used to return true in case of successful unscheduling).

There is one slight hitch : the schedule and unschedule method calls
are now asynchronous, for example :

---8<---

require 'rubygems'
require 'openwfe/util/scheduler'
include OpenWFE

s = Scheduler.new
s.start

job_id = s.schedule_in("5h") do
puts "it's time Doc Schweizer"
end

# then, immediately...

s.unschedule(job_id)

--->8---

The job will not get unscheduled, because the schedule and unschedule
operations now occur as the scheduler wakes up (by default every 0.250
second). Sleeping for something like 0.300 second before unscheduling
solves the issue.

This has not yet been packaged as a gem, because the bug was reported
indirectly.

If once this change is propagated (packaged in the next
openwferu-scheduler gem), you spot an issue, please report it here or
in OpenWFEru's issue tracker :
http://rubyforge.org/tracker/?atid=10023&group_id=2609&func=browse


Best regards, I wish you all a happy new year,

--
John Mettraux -///- http://jmettraux.openwfe.org

Reply all
Reply to author
Forward
0 new messages