Hello All,
I've been struggling for a month now to fix this issue and needed your help.
Apache Lounge(2.4) + mod_wsgi(4.6.6) + python 3.6.5 configuration is working pretty nice on my windows machine. Thanks to 'Graham Dumpleton blogs/posts' for that.
I'm facing one strange issue which is related to rpy2 package.
Just to give you the context that till now what I have done are as follows:
1. After setting up all the required environment I ran command -> mod_wsgi-express module-config
which gives the following scripts:
LoadFile "c:/worksetup/anaconda3/python36.dll"
LoadModule wsgi_module "c:/worksetup/anaconda3/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd"
WSGIPythonHome "c:/worksetup/anaconda3"
Added above scripts as it is in httpd.conf file without any changes as suggested by Graham Dumpleton himself.
2. After that I've created a virtual host to run my wsgi application on 'localhost:58188/wsgi'
httpd-vhosts.conf :
<VirtualHost *:58188>
ServerName localhost
LogLevel info
#WSGIProcessGroup test_optimization_group
#WSGIDaemonProcess test_optimization_group user=apache group=apache processes=1 threads=5 request-timeout=200
# Might stop multithreading
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias /wsgi "C:/Users/mysuser/PycharmProjects/test_optimization/test.wsgi"
DocumentRoot "C:/Users/myuser/PycharmProjects/test_optimization"
</VirtualHost>
3. It is working as expected. Everything is fine till now.
4. Now the problem comes here when I add these two below imports from rp2 package:
import rpy2.robjects as robjects
from rpy2.robjects import panda2sri
The moment I add these above imports in my test.wsgi script Apache server stops responding rather it hangs without any error.
However the same piece of code (the two rpy2 package imports) is working as expected in terminal.
I'm clueless at this point to how to fix this. I needed help on this ??
5. However I did some googling and found this url : https://bitbucket.org/rpy2/rpy2/issues/136/robjectsr-function-hangs-with-mod_wsgi which is pretty close to what I have been looking for, on windows machine:
In here the last three comments where Laurent Gautier is saying that 'R cannot do multithreading and using web servers on the Python side that use are not going to work well'
To try this fix, I tried adding WSGIProcessGroup & WSGIDaemonProcess to bring down the processes to 1 and etc.
WSGIProcessGroup test_optimization_group
WSGIDaemonProcess test_optimization_group user=apache group=apache processes=1 threads=5 request-timeout=200
But irony of the situation is WSGIDaemonProcess is not supported on windows.
As given here in this link :
Note that the WSGIDaemonProcess directive and corresponding features are not available on Windows.(from the official website)
6. I'm not sure whether fixing point 5 (above mentioned) would fix my issue or is there any fix is required for this.
Please let me know if I have missed anything. Any help on this is most welcome.
Thanks for your help in advance.