Skip to content
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

wrong number of arguments with Scheduler #86

Closed
ankane opened this issue Dec 30, 2020 · 3 comments
Closed

wrong number of arguments with Scheduler #86

ankane opened this issue Dec 30, 2020 · 3 comments

Comments

@ankane
Copy link

ankane commented Dec 30, 2020

Hey @ioquatix, thanks for this neat project! I was trying out the new scheduler with this example and ran into a few errors.

require "async"
require "net/http"

reactor = Async::Reactor.new
start = Time.now

Thread.new do 
  Fiber.set_scheduler(reactor.scheduler)

  %w[2.6 2.7 3.0].each do |version|
    Fiber.schedule do
      t = Time.now
      Net::HTTP.get('rubyreferences.github.io', "/rubychanges/#{version}.html")
      puts '%s: finished in %.3f' % [version, Time.now - t]
    end
  end
end.join

Stack trace

/Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/async-1.28.2/lib/async/task.rb:75:in `initialize': wrong number of arguments (given 0, expected 1..2) (ArgumentError)
	from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/async-1.28.2/lib/async/scheduler.rb:105:in `new'
	from /Users/user/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/async-1.28.2/lib/async/scheduler.rb:105:in `fiber'
	from go.rb:14:in `schedule'
	from go.rb:14:in `block (2 levels) in <main>'
	from go.rb:13:in `each'
	from go.rb:13:in `block in <main>'

It looks like @reactor needs to be passed to Task.new. After adding that, ran into undefined method 'resume' for #<Async::Task>.

@ioquatix
Copy link
Member

You need to use the Async construct as outlined in the documentation.

@ankane
Copy link
Author

ankane commented Dec 30, 2020

My bad, from #56, I thought it was an implementation of Fiber::SchedulerInterface.

@ankane ankane closed this as completed Dec 30, 2020
@ioquatix
Copy link
Member

It is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants