Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 27 lines (20 sloc) 0.57 kb
1b5fcc5 @kschiess + Locking mechanism based on files
authored
1
2 $:.unshift File.dirname(__FILE__) + '/../lib'
3
4 require 'procrastinate'
5
6 class Worker < Struct.new(:runtime)
7 def do_work
8 puts "#{Process.pid}: starting..."
9 runtime.lock('lock') do
10 puts "#{Process.pid}: holds lock"
11 sleep 0.1
12 puts "#{Process.pid}: releases"
13 end
14 puts "#{Process.pid}: done."
15 end
16 end
17
18 Procrastinate::Lock.base = '/tmp' # This will have to be moved into scheduler
19 scheduler = Procrastinate::Scheduler.start
8ea21ab @kschiess + renames 'create_proxy' to just 'proxy'
authored
20 worker = scheduler.proxy(Worker.new(scheduler.runtime))
1b5fcc5 @kschiess + Locking mechanism based on files
authored
21
22 10.times do
23 worker.do_work
24 end
25
26 scheduler.shutdown
Something went wrong with that request. Please try again.