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

NoMethodError: undefined method `post' for nil:NilClass #775

Closed
kamaradclimber opened this issue Nov 6, 2018 · 5 comments
Closed

NoMethodError: undefined method `post' for nil:NilClass #775

kamaradclimber opened this issue Nov 6, 2018 · 5 comments
Assignees
Labels
bug A bug in the library or documentation. high-priority Should be done ASAP.

Comments

@kamaradclimber
Copy link

* Operating system:                linux
* Ruby implementation:             Ruby
* `concurrent-ruby` version:       1.1.2
* `concurrent-ruby-ext` installed: no
* `concurrent-ruby-edge` used:     no

When using concurrent-ruby (1.1.2), the following code:

 task = Concurrent::TimerTask.new(run_now: true, execution_interval: 2) do
  sleep 5
end
task.execute

throws:

NoMethodError: undefined method `post' for nil:NilClass
from /home/g_seux/.gem/ruby/2.5.0/gems/concurrent-ruby-1.1.2/lib/concurrent/executor/timer_set.rb:101:in `ns_post_task'

This did not happen with 1.0.5

@delner
Copy link

delner commented Nov 6, 2018

Having this same issue. From what I can see Concurrent.global_io_executor now returns nil, so if the code you were depending on was getting an executor from that so it could call #post against it, it will raise this error.

That Concurrent.global_io_executor changed in implementation between 1.0.5 and 1.1.2: it used to return a ThreadPoolExecutor, it now is meant to return a CachedThreadPool. Problem is, that CachedThreadPool is undefined.

Adding require 'concurrent/executor/cached_thread_pool' to my code fixed this issue for me.

@pitr-ch pitr-ch self-assigned this Nov 7, 2018
@pitr-ch pitr-ch added bug A bug in the library or documentation. high-priority Should be done ASAP. in progress labels Nov 7, 2018
@pitr-ch
Copy link
Member

pitr-ch commented Nov 7, 2018

From the fix I deduce that you are requiring just part of the concurrent-ruby not the whole gem. Is that correct? That's not officially supported at the moment (only require 'concurrent' is) so even if we try to make it work sometimes problems get through, see #714. I'll release 1.1.3 with a fix, thanks for investigating.

@pitr-ch
Copy link
Member

pitr-ch commented Nov 7, 2018

1.1.3 is out, please reopen if it did not fix the issue.

@pitr-ch pitr-ch closed this as completed Nov 7, 2018
@ghost ghost removed the in progress label Nov 7, 2018
@delner
Copy link

delner commented Nov 7, 2018

@pitr-ch I can't speak for @kamaradclimber but this is the case on my end; we were only including Future.

Thanks for the quick release! Works for us.

@pitr-ch
Copy link
Member

pitr-ch commented Nov 7, 2018

Thanks for confirming. This type of issues should not happen again after #714 is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug in the library or documentation. high-priority Should be done ASAP.
Projects
None yet
Development

No branches or pull requests

3 participants