INTRO

‘procrastinate’ does the process handling so you don’t have to. It leaves you to concentrate on what to run when, not orchestration of low level details.

This library will be ideal for quickly scheduling of a lot of long running tasks. You can easily control how many processes are run at any time. To get at/cron like scheduling, combine this library with ‘rufus-scheduler’.

SYNOPSIS

require 'procrastinate'
include Procrastinate

class Worker
  def do_work
    puts "> Starting work in process #{Process.pid}"
    sleep 2
    puts "< Work completed in process #{Process.pid}"
  end
end

scheduler = Scheduler.start(SpawnStrategy::Throttled.new(5))
worker = scheduler.create_proxy(Worker.new)

10.times do 
  worker.do_work
end

scheduler.shutdown

The above example will output something like

> Starting work in process 6651
> Starting work in process 6652
> Starting work in process 6653
> Starting work in process 6654
> Starting work in process 6655
< Work completed in process 6651
< Work completed in process 6652
< Work completed in process 6653
< Work completed in process 6654
< Work completed in process 6655
> Starting work in process 6659
> Starting work in process 6660
> Starting work in process 6656
> Starting work in process 6657
> Starting work in process 6658
< Work completed in process 6659
< Work completed in process 6660
< Work completed in process 6656
< Work completed in process 6657
< Work completed in process 6658

COMPATIBILITY

This library runs with at least Ruby 1.8.7 and Ruby 1.9. Ruby 1.9 support might be spotty, because the threading primitives in Ruby 1.9 are still somewhat buggy.

KNOWN BUGS

Due to the way we handle signal traps, you cannot start more than one Scheduler. We might allow that in the future.

Also: signal traps interact with other libraries and might cause things to break. This is the real world.

STATUS

We’re still adding features that we believe must be in 1.0. What is there mostly works; Multi-Threading is always a difficult topic and we’re glad to receive bug reports.

Please see the LICENSE file for license information.

© 2010 Kaspar Schiess, Patrick Marchi