Package: libapache2-mod-wsgi-py3 Version: 4.7.1-3+b1 Severity: normal 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>. -- System Information: Debian Release: 11.0 APT prefers stable-security APT policy: (500, 'stable-security'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 5.13.4-x86_64-linode146 (SMP w/2 CPU threads) Locale: LANG=C, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages libapache2-mod-wsgi-py3 depends on: ii apache2-bin [apache2-api-20120211] 2.4.48-3.1+deb11u1 ii libc6 2.31-13 ii libpython3.9 3.9.2-1 ii python3 3.9.2-3 libapache2-mod-wsgi-py3 recommends no packages. libapache2-mod-wsgi-py3 suggests no packages. -- no debconf information