Python ctypes MemoryError in fcgi process from PIL library

后端 未结 3 1926
萌比男神i
萌比男神i 2020-12-16 01:36

I\'m trying to run Django on shared hosting (Bluehost). I\'m using functionality that requires PIL. PIL imports and works from an interactive shell, but in my fcgi process i

3条回答
  •  自闭症患者
    2020-12-16 02:29

    Just to expand on eos87's answer a bit, this does fix the problem for me as well, and judging by the comment before that line, it sounds like it was added as a workaround to a windows bug, but the workaround is apparently causing trouble of its own. Here's the bit at the end of __init__.py:

    # XXX for whatever reasons, creating the first instance of a callback
    # function is needed for the unittests on Win64 to succeed.  This MAY
    # be a compiler bug, since the problem occurs only when _ctypes is
    # compiled with the MS SDK compiler.  Or an uninitialized variable?
    CFUNCTYPE(c_int)(lambda: None)
    

    It looks like it's safe to remove.

    FWIW, this issue showed up for me on a Centos 5.7 x64 box when using python 2.6 as installed (in parallel with python 2.4) from epel. The file was found here: /usr/lib64/python2.6/ctypes/__init__.py

    Also note that the exception that shows up is a MemoryError which according to strace results from a segmentation fault immediately (though perhaps coincidentally) after a call to munmap; and it only shows up when running as FastCGI.

提交回复
热议问题