Open jeremycochoy opened 5 years ago
It seems PyCall works with Pillow when it runs with pry (the Ruby interpreter).
PYTHON=python3 pry
pry> def test()
pry* pil_img = PyCall.import_module('PIL.Image')
pry* im = pil_img.open('photo.jpg')
pry* im.rotate(30).save('photo30.jpg')
pry* end
pry> test
=> nil
I'm using Ruby 2.4.2p198, Python 3.7.0, pycall 1.0.3 on Mac.
I'm also examine pillow on pry with Ruby 2.6.4, Python 3.7.4, and Pillow 6.1.0, and the problem is not reproduced as @chibash said.
@jeremycochoy Could you give me the small example code to reproduce your problem?
Importing pillow and opening an image make a sinatra server get stuck (seems like the python function never return). I don't really know what are the details related to this problem, I can only say it happened both on linux and mac, that it seams to be related to usage of the pillow library, and also happen when using fastai (which rely on pillow for opening images). I have tried different implementation (fastai, opening the image with pillow by hand) but still get this problem. Not using fastai and pillow doesn't create any problem and everything runs fines. I have tried both with and without
PyCall.without_gvl
.I don't know if the same troubles happen when using directly the ruby interpreter. Sadly, I don't have much time to investigate.
Steps to reproduce
make a function calling pillow:
Call the cally function from sinatra (ruby) in any get or post request.
The function sub seams to never return. ("ok" is never displayed, but any print added to sub will be displayed, until the function sub returns)
I have no idea where it comes from, and feel actually stupid that pytorch is working but not the pillow library. 🤣
Expected behavior
"ok" should be printed and then ruby should get the hand back
Actual behavior
Get stup inside python in master and 1.3.0-dev. Segfault with older versions.
System configuration
Ruby version: 2.6.3 with rbenv Sinatra version: 2.0.5 Server version: use bundle exec rackup with default configuration (i.e. WEBrick)