Skip to content

Commit

Permalink
Way, way backwards compatibility for beanstalk-export.rb
Browse files Browse the repository at this point in the history
I had to do an export from a really old version of beanstalkd that
didn't support reserve-with-timeout.  This works, but it's not very
efficient.  The code will try to do the most efficient thing and
fallback on less efficient/more dumb things as it needs to.
  • Loading branch information
dustin committed Jan 16, 2009
1 parent c1d37b0 commit 5906551
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/beanstalk-export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ def kick(n=10000000)

def export(t)
loop do
job = BS.reserve 0
job = begin
BS.reserve 0
rescue Beanstalk::BadFormatError
# Hacky way to handle a really old version.
st = BS.stats_tube t
remaining = st['current-jobs-urgent'] + st['current-jobs-ready']
raise Beanstalk::TimedOut if remaining == 0
BS.reserve
end

# Record the time the job should actually start.
d = Time.now.to_i + job.delay
Expand Down

0 comments on commit 5906551

Please sign in to comment.