Python Grpc client service method does not return when called from httpd on Oracle Linux

105 views
Skip to first unread message

Manosh Padannayil

unread,
Oct 14, 2020, 3:40:18 PM10/14/20
to modwsgi
Hello All,
   I am getting the exact same issue reported in the below thread but for Oracle Linux OS.

Issue: Python Grpc client service method does not return when called from httpd on Oracle Linux. It works from eclipse in OSX. Works from python terminal in Oracle Linux, fails only when it is called from within httpd in Oracle Linux.

Configuration
Oracle Linux 7.8
httpd-2.4.41, 2.4.46
Python 3.8.0, 3.9.0
  Django 2.2.6
  grpcio 1.32.0
  grpcio-tools 1.32.0
  mod-wsgi 4.7.1
  mod-wsgi-httpd 2.4.41.1

Pseudo code:
from my.service import my_service_pb2_grpc
with open('/path/to/pem/file', 'rb') as f:
  trusted_certs = f.read()
with open('path/to/key/file', 'rb') as f:
  cert_key = f.read()
cred = grpc.ssl_channel_credentials(root_certificate=trusted_certs, private_key=cert_key, certificate_chain=trusted_certs)
channel = grpc.secure_channel('{}:{}'.format('server_url',443), cred)
stub = my_service_pb2_grpc.MyServiceStub(channel)
response = stub.MyMethod(MyRequest)

I tried with options grpc.keepalive_timeout_ms and   grpc.keepalive_time as 10000, but no luck.

Could anyone please help me on this?

Thanks and Regards,
Manosh Padannayil

Graham Dumpleton

unread,
Oct 14, 2020, 4:41:09 PM10/14/20
to mod...@googlegroups.com
Are you forcing the use of the main Python interpreter?


Likely their Python wrapper module isn't designed to work in Python sub interpreters.

Also, are you using system Apache or mod_wsgi-express? Your configuration list is confusing since you mention multiple Apache versions as well as pip installed mod_wsgi and mod_wsgi-httpd packages.

If you are using system Apache, you should not have mod_wsgi-httpd package installed and doing so could screw things up if trying to use mod_wsgi install against it with system Apache.

Finally, are you using system Python packages, or Python from Python Software Foundation. You cannot use Anaconda Python if you want to be able to use SSL in Apache and Python.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/d50c82c4-0f9a-4d22-9c30-affac1877e3en%40googlegroups.com.

Manosh Padannayil

unread,
Oct 19, 2020, 7:08:28 AM10/19/20
to modwsgi
Hi Graham,
    Thanks for the reply. I tried different options as mentioned in the reply. Tried different versions of Python and http, but no luck.
Actually, I compiled, httpd and python source code and installed the python package mod_wsgi. 

Below are the detailed steps I did;
In a fresh VM: Oracle Linux 7.8
1.  yum upgrade
yum update
yun install openssl-devel
yun install libffi-devel

2. Compiled the following latest packages with prefix as  --prefix=/path/to/apache/home
pcre2-10.35
expat-2.2.10
apr-1.6.5
apr-util-1.6.1
httpd-4.4.46 : compiled with --enable-ssl --enable-so

3. Compiled python-3.9.0 with prefix as --prefix=/path/to/python/install/home

4. Install python packages: all latest versions:
python3 -m pip install grpcio grpcio-tools protobuf mod-wsgi DJango

4. Configured /path/to/apache/home/conf/httpd.conf as below
    
    Listen 9000
    User my_username
    Group my_group
    ServerName localhost:9000
<Directory "/">
Require all granted
</Directory>
WSGIPythonHome /path/to/python/install/home
LoadModule wsgi_module /path/to/python/install/home/lib/python3.9/site-packages/mod_wsgi/server/mod_wsgi-py39-cpython-39-x86_64-linux-gnu.so

Started the apache as /path/to/apache/home/bin/apachectl start

Below are the logs obtained.

If I understood correctly from last reply, the python subinterpreter is loaded instead of primary interpreter when a GRPC api is invoked, causing the deadlock.

Please let me know how to get rid of this deadlock issue with grpc client in mod_wsgi.

Thanks and Regards,
Manosh Padannayil


IMG_3963.jpg

Graham Dumpleton

unread,
Oct 19, 2020, 7:15:09 AM10/19/20
to mod...@googlegroups.com
If you tried:

    WSGIApplicationGroup %{GLOBAL}

as mentioned in the documentation, then next try:


to get out stack traces as to where it is getting stuck.

Note you will need to update the code example in that doc to work with Python 3 as appears to still be for Python 2.

Graham

Reply all
Reply to author
Forward
0 new messages