pycall.rb
pycall.rb copied to clipboard
PyCall hangs after one call with Rails + SciKit Learn
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!
Please show the code and the conditions for reproducing this error.
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
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.