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

I don't think this is thread-safe #2

Open
fregas opened this issue Apr 4, 2013 · 6 comments
Open

I don't think this is thread-safe #2

fregas opened this issue Apr 4, 2013 · 6 comments

Comments

@fregas
Copy link

fregas commented Apr 4, 2013

I'm trying to use this with the parallel gem inside a thread and I get this error:

"fiber called across threads"

I'm doing something like this:

results = Parallel.map([1,2,3,4,5,6,7],:in_threads=>2) do |item|
  RandomWord.nouns.next
end
@benshine
Copy link

benshine commented Jan 3, 2015

I get the same issue when calling RandomWord.nouns.next in subsequent requests in Rails 4.

@mmhan
Copy link

mmhan commented Jan 30, 2015

I got the same issue with this in Rails 4 especially while running cucumber. I was trying to fork this and see if there's anything I can do to contribute (at least write a test), but somehow rake spec isn't running.

Here's my bundle show

  * activesupport (4.2.0)
  * bundler (1.7.4)
  * coderay (1.1.0)
  * diff-lcs (1.1.3)
  * git (1.2.9.1)
  * i18n (0.7.0)
  * jeweler (1.6.4)
  * json (1.8.2)
  * machinist (2.0)
  * method_source (0.8.2)
  * minitest (5.5.1)
  * pry (0.10.1)
  * rake (10.4.2)
  * rspec (2.3.0)
  * rspec-core (2.3.1)
  * rspec-expectations (2.3.0)
  * rspec-mocks (2.3.0)
  * slop (3.6.0)
  * thread_safe (0.3.4)
  * tzinfo (1.2.2)
  * yard (0.6.8)

Below is the error I received when I run rspec

undefined method `run_all' for []:Array

with Unable to find matching line from backtrace message.

@mmhan
Copy link

mmhan commented Jan 30, 2015

The above problem regarding rspec and undefined method run_all' for []:Array was solved by upgrading rspec to ~> 2.4.0

Still couldn't reproduce the bug in spec though.

@jtokoph
Copy link

jtokoph commented May 31, 2017

I'm getting FiberError (fiber called across threads): when calling next

@pezra
Copy link
Contributor

pezra commented May 31, 2017

@jtokoph, in what context? fwiw, this gem is not thread safe. a random word instance should only be used in one thread at a time.

@jtokoph
Copy link

jtokoph commented Jun 1, 2017

Using threads in puma which would explain the issue.

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

5 participants