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

Pillow library freeze PyCall ? #93

Open
jeremycochoy opened this issue Jun 7, 2019 · 2 comments
Open

Pillow library freeze PyCall ? #93

jeremycochoy opened this issue Jun 7, 2019 · 2 comments

Comments

@jeremycochoy
Copy link

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:

def cally():
  print("hey")
  sub()
  print("ok")

def sub():
  // Do some naugthy stuff with 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)

@chibash
Copy link

chibash commented Jul 27, 2019

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.

@mrkn
Copy link
Owner

mrkn commented Sep 5, 2019

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?

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

3 participants