mrkn / pycall.rb

Calling Python functions from the Ruby language
MIT License
1.05k stars 72 forks source link

pycall freezes and never resolves during a controller function #157

Closed maks112v closed 2 years ago

maks112v commented 2 years ago

I am getting an issue with pycall specifically in the ruby-spacy package. I am able to import it and run nlp.read inside the console without issues but while running the same code on controller it hangs and never resolves without no issues printing

Current Code

require "ruby-spacy"

class Api::V1::Spacy < ApplicationController

  def inbound
    nlp = Spacy::Language.new(Rails.root.join("app/assets/model"))
    doc = nlp.read("Hello world")
    puts doc.ents
    return render json: { doc.ents }
  rescue => e
    puts e
    head :internal_server_error
  end
end

ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [arm64-darwin21] Rails 7.0.2.3 Python 3.10.1 with shared enabled

hoblin commented 8 months ago

Hey @maks112v I have the same issue with ruby-spacy. It hangs the process when I call Spacy::Language.new in a server process or in a background job. Did you manage to solve it?