Skip to content Skip to sidebar Skip to footer

Rpy2 In A Flask App: Fatal Error: Unable To Initialize The JIT

I have a Flask app, and I'm trying to add a RESTful endpoint that uses rpy2 to load a model from a .rds file. When I run my test script with python3 testscript.py that contains imp

Solution 1:

Multithreading is often used by default when Python is used in web servers/services.

Check the relevant section in the doc: https://rpy2.github.io/doc/v3.3.x/html/rinterface.html#multithreading


Solution 2:

The original post is correct. The fix would seem to be an external one, like setting up an independent service that doesn't multithread -- using a Redis server, for instance.

Here's my output, with rpy2 3.3.5 python 3.6.8 dash 1.15.0 flask 1.1.2

[Fri Aug 28 01:51:41.665103 2020] [wsgi:error] [pid 4707] [client 10.93.203.56:53374] Truncated or oversized response headers received from daemon process 'flask_app': /var/www/html/flask_app.wsgi
[Fri Aug 28 01:58:08.393491 2020] [mpm_prefork:notice] [pid 4702] AH00170: caught SIGWINCH, shutting down gracefully
[Fri Aug 28 01:58:09.523054 2020] [core:notice] [pid 4754] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Fri Aug 28 01:58:09.523784 2020] [suexec:notice] [pid 4754] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Aug 28 01:58:09.534708 2020] [so:warn] [pid 4754] AH01574: module rewrite_module is already loaded, skipping
[Fri Aug 28 01:58:09.537129 2020] [lbmethod_heartbeat:notice] [pid 4754] AH02282: No slotmem from mod_heartmonitor
[Fri Aug 28 01:58:09.539013 2020] [mpm_prefork:notice] [pid 4754] AH00163: Apache/2.4.6 (CentOS) mod_wsgi/4.6.5 Python/3.6 configured -- resuming normal operations
[Fri Aug 28 01:58:09.539036 2020] [core:notice] [pid 4754] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
Error: C stack usage  1087224955812 is too close to the limit
Error: C stack usage  1087224955860 is too close to the limit
Error: C stack usage  1087224955332 is too close to the limit
Fatal error: unable to initialize the JIT

Have already pushed the code to a subprocess which is imported and then called within a wrapper as suggested here: https://rpy2.github.io/doc/v3.3.x/html/rinterface.html#multithreading

from rpy2.rinterface_lib import openrlib

....

with openrlib.rlock:
    import farrington2
    d=farrington2.main()
    pass

Post a Comment for "Rpy2 In A Flask App: Fatal Error: Unable To Initialize The JIT"