-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Help request] Local variable outside of Disc::WorkerGroup was out of scope #12
Conversation
Oh, you're right about that being broken. Thanks for catching it. I'm on my phone right now, but the PR is definitely mergeable! 😄 Would you mind opening an issue for your problem with Rails/ActiveJob so that it's not lost in the merged PR? Thanks! ❤️ ❤️ ❤️ |
Local variable outside of Disc::WorkerGroup was out of scope
Just pushed Regarding not having jobs enqueued: try running Thanks a lot for trying Disc and open a PR/issue here, it's incredibly helpful to us :) |
@pote You are correct: using
NOTE: There are two jobs here: one from ActiveJob, and one directly on the service object, as you can see in the controller code at the bottom of this comment. However, the process running # disc_job.rb
require 'disc'
class DiscJob
include Disc::Job
disc queue: "urgent"
def perform(*args)
STDOUT.puts args.inspect
process_id = Process.pid
thread_id = Thread.current.object_id
STDOUT.puts "process #{process_id}; thread #{thread_id}"
end
end With Rails, I invoke it through this controller, though I just require the class DiscsController < ApplicationController
def send_delayed_job
STDOUT.puts "Through ActiveJob"
DiscActiveJob.perform_later
STDOUT.puts "Through Disc"
DiscJob.enqueue("random_argument") # line I run in IRB
render text: "OK"
end
end I'm happy to open something with ActiveJob, but because I'm having trouble invoking it manually I don't know that it's isolated to the ActiveJob adapter. Thanks for all your hard work - I'm very excited to use Disc/Disque. |
Ahh, got it, Test with the latest version and let me know if it's fixed. :) |
@pote Thank you for pushing the fix! It works on my machine. Thanks for your help and communication. :) |
🎉 ❤️ ❤️ ❤️ ❤️ 🎉 |
Hi Pote,
I'm not sure if this is more of help request or a pull request.
I had tried to start Disc with the Rails/ActiveJob integration aspect of the readme. The problem arose when I tried to run:
In IRB, you cannot access a local variable defined out of the scope of a class, but you can reference a method. However, in this case even a method or instance variable does not share scope with the internals of the
Disc::WorkerGroup
class (I tried a little hacking on it). I assume this has to do withmethod_missing
and details I do not fully grok.Ex. 1 Failing code.
Using the code in the pull request, I was able to move past this error message. However, I do not see any enqueued jobs from Rails showing up in my running
disc
process.If anything stands out immediately as having been a problem on another machine and there's an easy solution, let me know because I'd love to try out Disc/Disque. Please do not merge this PR as it has not fixed my issue.