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

PyCall hangs after one call with Rails + SciKit Learn #95

Open
StephenFiser opened this issue Aug 23, 2019 · 4 comments
Open

PyCall hangs after one call with Rails + SciKit Learn #95

StephenFiser opened this issue Aug 23, 2019 · 4 comments

Comments

@StephenFiser
Copy link

I'm getting the following error the first time that sklearn is imported:

/Users/stephen/.rvm/rubies/ruby-2.6.2/bin/ruby: No such file or directory -- from multiprocessing.semaphore_tracker import main;main(27) (LoadError)

I'm not a python dev, but it seems semaphore has something to do with parallel processing.

When I'm in a rails console, I can run my code without issues (still get the warning). In the web application, it runs once, then it hangs. If I navigate away from the page where it runs, the app is fine. If I come back to the previous page, it crashes entirely. Would love some help!

@mrkn
Copy link
Owner

mrkn commented Sep 5, 2019

Please show the code and the conditions for reproducing this error.

@YaarPatandarAA
Copy link

Having same problem. In my instance I am using a method in an external python module and this is in a Rails controller. After one call is made, I cannot make another call. The second call will hang.

 require 'pycall'
 PyCall.init('python3')
 PyCall.sys.path.append File.dirname("PATH_TO_MODULE")

 def test_python
   mod = PyCall.import_module('MODULE_NAME')
   val = mod.SOME_MODULE_METHOD()

   render json: 
 end

@hoblin
Copy link

hoblin commented Dec 29, 2023

I have the same problem when I use https://github.com/yohasebe/ruby-spacy (which is based on PyCall).
It works when I call Spacy::Language.new("en_core_web_sm") in the rails console. When I call it from the server process (puma) or inside a background job (I tried sidekiq and https://github.com/basecamp/solid_queue) the worker just stuck and the only way i found to unstuck it is to kill the process.

@otaviogaiao
Copy link

I'm having the same issue. My Rails app hangs forever when on eager_load = false. The line of code that is doing it is:

PyCall.sys.path.append('./app/lib/python_helpers')

Its on a initializer.

My app is very simple, and it freezes just by having this line.

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