| In: |
lib/rq-2.3.1/locker.rb
|
| Parent: | MainHelper |
a Locker simply obtains an exclusive lock on a queue’s lock and then runs and arbitrary command which is taken from the command line only. it’s use is simply to allow unforseen applications to coordinate access to the queue
# File lib/rq-2.3.1/locker.rb, line 18
18: def lock
19: #--{{{
20: set_q
21: ltype = @argv.shift
22: debug{ "ltype <#{ ltype }>" }
23: read_only =
24: case ltype
25: when /^\s*r(?:ead)?|^\s*sh(?:ared)?/io
26: true
27: when /^\s*w(?:rite)?|^\s*ex(?:clusive)?/io
28: false
29: else
30: raise "lock type must be one of (r)ead|(sh)ared|(w)rite|(ex)clusive, not <#{ ltype }>"
31: end
32: cmd = @argv.join(' ').strip
33: raise "no command given for lock type <#{ ltype }>" if cmd.empty?
34: debug{ "cmd <#{ cmd }>" }
35: @q.lock(:read_only => read_only){ Util::system cmd }
36: #--}}}
37: end