Dear Maintainer,
Since upgrading to bullseye, a WSGI script which imports psycopg2
fails sometimes (randomly?) with:
[Sun Aug 29 17:54:07.215719 2021] [wsgi:error] [pid 7705] [client 127.0.0.1:33774] mod_wsgi (pid=7705): Exception occurred processing WSGI script '/var/www/wsgis-bortzmeyer/ni.py'.
[Sun Aug 29 17:54:07.215893 2021] [wsgi:error] [pid 7705] [client 127.0.0.1:33774] Traceback (most recent call last):
[Sun Aug 29 17:54:07.215967 2021] [wsgi:error] [pid 7705] [client 127.0.0.1:33774] File "/var/www/wsgis-bortzmeyer/ni.py", line 11, in <module>
[Sun Aug 29 17:54:07.216000 2021] [wsgi:error] [pid 7705] [client 127.0.0.1:33774] import psycopg2
[Sun Aug 29 17:54:07.216026 2021] [wsgi:error] [pid 7705] [client 127.0.0.1:33774] File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 51, in <module>
[Sun Aug 29 17:54:07.216051 2021] [wsgi:error] [pid 7705] [client 127.0.0.1:33774] from psycopg2._psycopg import ( # noqa
[Sun Aug 29 17:54:07.216087 2021] [wsgi:error] [pid 7705] [client 127.0.0.1:33774] SystemError: initialization of _psycopg raised unreported exception
psycopg2 on the same machine always work when ran outside of WSGI.
Setting WSGIApplicationGroup %{GLOBAL} in the configuration cures the
problem.
I checked that there is only one Python (the Debian package) on the
machine.
A similar case is reported in <https://stackoverflow.com/questions/67673276/import-psycopg2-systemerror-initialization-of-psycopg-raised-unreported-exce>.