Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use inf value instead of math.huge.
Problem on Windows build where Redis convert `math.huge` to `1.#INF` value
and then fail accept this value as float value.
  • Loading branch information
moteus committed Feb 3, 2017
1 parent cd7f5fb commit c3d7847
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion base.lua
Expand Up @@ -152,7 +152,7 @@ function Qless.jobs(now, state, ...)
elseif state == 'depends' then
return queue.depends.peek(now, offset, count)
elseif state == 'recurring' then
return queue.recurring.peek(math.huge, offset, count)
return queue.recurring.peek('+inf', offset, count)
else
error('Jobs(): Unknown type "' .. state .. '"')
end
Expand Down
2 changes: 1 addition & 1 deletion job.lua
Expand Up @@ -714,7 +714,7 @@ function QlessJob:timeout(now)
self:history(now, 'timed-out')
local queue = Qless.queue(queue_name)
queue.locks.remove(self.jid)
queue.work.add(now, math.huge, self.jid)
queue.work.add(now, '+inf', self.jid)
redis.call('hmset', QlessJob.ns .. self.jid,
'state', 'stalled', 'expires', 0)
local encoded = cjson.encode({
Expand Down
11 changes: 7 additions & 4 deletions queue.lua
Expand Up @@ -25,8 +25,11 @@ function Qless.queue(name)
return redis.call('zrem', queue:prefix('work'), unpack(arg))
end
end, add = function(now, priority, jid)
if priority ~= '+inf' then
priority = priority - (now / 10000000000)
end
return redis.call('zadd',
queue:prefix('work'), priority - (now / 10000000000), jid)
queue:prefix('work'), priority, jid)
end, score = function(jid)
return redis.call('zscore', queue:prefix('work'), jid)
end, length = function()
Expand All @@ -38,18 +41,18 @@ function Qless.queue(name)
queue.locks = {
expired = function(now, offset, count)
return redis.call('zrangebyscore',
queue:prefix('locks'), -math.huge, now, 'LIMIT', offset, count)
queue:prefix('locks'), '-inf', now, 'LIMIT', offset, count)
end, peek = function(now, offset, count)
return redis.call('zrangebyscore', queue:prefix('locks'),
now, math.huge, 'LIMIT', offset, count)
now, '+inf', 'LIMIT', offset, count)
end, add = function(expires, jid)
redis.call('zadd', queue:prefix('locks'), expires, jid)
end, remove = function(...)
if #arg > 0 then
return redis.call('zrem', queue:prefix('locks'), unpack(arg))
end
end, running = function(now)
return redis.call('zcount', queue:prefix('locks'), now, math.huge)
return redis.call('zcount', queue:prefix('locks'), now, '+inf')
end, length = function(now)
-- If a 'now' is provided, we're interested in how many are before
-- that time
Expand Down

0 comments on commit c3d7847

Please sign in to comment.