You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resque-loner does not work when also using the resque-status plugin since the latter adds a job_id to the payload and so that confuses resque-loner into thinking that the job does not already exist and thus allows. I am not sure there’s much to do about this but I’m just opening this ticket as a reference for others.
For now, I’m trying to work around the issue by monkey patching the redis_key function to remove the job_id from the payload before calculating the md5 hash.
Here’s the code:
# Monkey patch resque-loner so that it plays ball with resque-status.moduleResquemodulePluginsmoduleUniqueJobmoduleClassMethodsdefredis_key(payload)payload=decode(encode(payload))# This is the cycle the data goes when being enqueued/dequeuedjob=payload[:class] || payload['class']args=(payload[:args] || payload['args'])# This is a quick hack so that this library works with resque-status.# Resque-status adds a job_id as the first element of args, and this# messes up how resque-loner determines if a job is already queued or# not. By removing the job_id, everything should be A-OK. Only workers# that include resque-loner should be affected. Small caveat, when calling# Resque.enqueued? that comes with resque-loner, there’s no job_id to# remove so we must do nothing in that case.ifrespond_to?(:create)args.shiftunlesscaller.index{ |e| e =~ /enqueued\?/}endargs.map!do |arg|
arg.is_a?(Hash) ? arg.sort : argenddigest=Digest::MD5.hexdigest(encode(class: job,args: args))digestendendendendend
The text was updated successfully, but these errors were encountered:
Resque-loner does not work when also using the resque-status plugin since the latter adds a job_id to the payload and so that confuses resque-loner into thinking that the job does not already exist and thus allows. I am not sure there’s much to do about this but I’m just opening this ticket as a reference for others.
For now, I’m trying to work around the issue by monkey patching the redis_key function to remove the job_id from the payload before calculating the md5 hash.
Here’s the code:
The text was updated successfully, but these errors were encountered: