Closed tevykak closed 3 months ago
Reproduced a similar case on a platform with AMD processor. Intel is totally fine.
If I run PyCall.import_module('whatever module name here')
inside Thread.new
block, it crashes. If I import_module outside Thread.new
but then call something inside Thread.new
, it also crashes.
@fuck-lukashenko pycall doesn't support multithreading. Please call Python only from the main thread.
@tevykak Could you please check whether Python was called from non-main threads when SEGV occurred? If so, please prevent calling Python from non-main threads because the current pycall can support only the main thread.
@tevykak If this problem isn't related to multithreading, please reopen the issue.
I was having the same issue, segfaults on almost every function call. Can confirm putting the code in the main thread fixed the problem.
@tevykak could you give an example of the pandas code that caused your crash? I believe I have a similar example, but mine is using a more complicated library than pandas. It would help me produce a minimal repro if you could give a pandas snippet that crashes for you.
I believe the issue is that Puma ALWAYS starts requests in a thread, even if you set threads=1, it will still do requests on a different thread than initialized the code, which is not safe for pycall.
See main tracking issue for thread safety: https://github.com/mrkn/pycall.rb/issues/96
I have a rails project using pycall and pandas.
I use these gems in a dedicated service. It works on production (heroku) and in a local rails console, I can run some data calculations.
But in a local rails server (I call the service from a controller), it doesn't work anymore: every time
pycall
is called, the server crashes.Apparently, the error comes from
pytypeobject_wrapper.rb
but I have absolutely no idea why and I don't know how to fix it. Please, help? 🥲Backtrace:
App rails config:
I also try to run my server with virtualenv but it doesn't change anything, I have the same error.