[Résolu] RuntimeError: populate() isn't reentrant - libresurf - 24-05-2025
Bonjour,
Je n'arrive pas à utiliser CrèmeCRM 2.6 avec Apache2 2.4.63 sous debian trixie.
Lors de la connexion au serveur depuis mon navigateur web, j'obtiens une erreur "500 Internal Server Error" (The server encountered an internal error or misconfiguration and was unable to complete your request.)
Les logs d'Apache renvoient alors :
Code : [wsgi:error] [pid 7084:tid 7103] [remote *********:47720] mod_wsgi (pid=7084): Failed to exec Python script file '/srv/www/my_project/my_project/wsgi.py'.
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] mod_wsgi (pid=7084): Exception occurred processing WSGI script '/srv/www/my_project/my_project/wsgi.py'.
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] Traceback (most recent call last):
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] File "/srv/www/my_project/my_project/wsgi.py", line 19, in <module>
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] application = get_wsgi_application()
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] django.setup(set_prefix=False)
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/django/__init__.py", line 24, in setup
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] apps.populate(settings.INSTALLED_APPS)
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/creme/__init__.py", line 33, in _hooked_populate
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] _original_populate(self, installed_apps)
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/django/apps/registry.py", line 83, in populate
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] raise RuntimeError("populate() isn't reentrant")
[wsgi:error] [pid 7084:tid 7103] [remote *********:47720] RuntimeError: populate() isn't reentrant
Le problème semble venir d'une boucle avec l'emploi la directive populate() dans les fichiers Python.
Savez-vous comment résoudre le problème ?
Voici la configuration de mon site :
Code : <VirtualHost *:80>
ServerName crm.lan.local
ServerAdmin admin@mail.lan.local
ServerSignature Off
DocumentRoot /srv/www/my_project
<IfModule mod_wsgi.c>
WSGIDaemonProcess crm.lan.local python-home=/srv/www/venv/creme_2_6/ python-path=/srv/www/my_project
WSGIProcessGroup crm.lan.local
WSGIScriptAlias / /srv/www/my_project/my_project/wsgi.py process-group=crm.lan.local
</IfModule>
Alias /site_media/ /srv/www/my_project/my_project/media/static/
<Directory /srv/www/my_project/my_project/media/static>
Options Indexes SymLinksIfOwnerMatch
AllowOverride Limit FileInfo Indexes
Require all granted
</Directory>
<Directory /srv/www/my_project/my_project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory />
Options +Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/my_project_error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/my_project_access.log combined
</Virtualhost>
À la toute première connexion au serveur, j'ai le message suivant qui est peut-être la cause du problème précédent :
Code : mod_wsgi (pid=194): Failed to exec Python script file '/srv/www/my_project/my_project/wsgi.py'.
mod_wsgi (pid=194): Exception occurred processing WSGI script '/srv/www/my_project/my_project/wsgi.py'.
Traceback (most recent call last):
File "/srv/www/my_project/my_project/wsgi.py", line 19, in <module>
application = get_wsgi_application()
File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/creme/__init__.py", line 33, in _hooked_populate
_original_populate(self, installed_apps)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/django/apps/config.py", line 269, in import_models
self.models_module = import_module(models_module_name)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/importlib/__init__.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/creme/emails/models/__init__.py", line 5, in <module>
from .sending import ( # NOQA
...<3 lines>...
)
File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/creme/emails/models/sending.py", line 39, in <module>
from creme.creme_core.utils.crypto import SymmetricEncrypter
File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/creme/creme_core/utils/crypto.py", line 27, in <module>
from cryptography.fernet import Fernet, InvalidToken
File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/cryptography/fernet.py", line 14, in <module>
from cryptography.exceptions import InvalidSignature
File "/srv/www/venv/creme_2_6/lib/python3.13/site-packages/cryptography/exceptions.py", line 9, in <module>
from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
ImportError: PyO3 modules do not yet support subinterpreters, see https://github.com/PyO3/pyo3/issues/576
RE: RuntimeError: populate() isn't reentrant - genglert - 27-05-2025
Bonjour,
alors nous n'avons pas (encore) reproduit votre souci, mais après quelques recherches je vois quel pourrait prêt le souci.
Dans le fichier "creme/creme_core/utils/crypto.py", pouvez vous mettre les 3 lignes qui commencent par
'from cryptography' en commentaire (idéalement il faudrait déplacer ces imports dans les méthodes "__init__" & "decrypt", mais c'est juste un test et je ne sais pas si vous savez le faire) et me dire si ça corrige le problème ?
RE: RuntimeError: populate() isn't reentrant - libresurf - 27-05-2025
(27-05-2025, 09:39)genglert a écrit : Dans le fichier "creme/creme_core/utils/crypto.py", pouvez vous mettre les 3 lignes qui commencent par
'from cryptography' en commentaire (idéalement il faudrait déplacer ces imports dans les méthodes "__init__" & "decrypt", mais c'est juste un test et je ne sais pas si vous savez le faire) et me dire si ça corrige le problème ?
Bonjour @genglert,
Oui, c'est exactement ça !
Après correction en mettant en commentaire les trois lignes commençant par 'from cryptography', tout fonctionne et j'arrive à me connecter à CrèmeCRM ! 
Je n'ai plus du tout d'erreurs dans mes fichiers de logs.
Merci vivement !
RE: [Résolu] RuntimeError: populate() isn't reentrant - genglert - 27-05-2025
OK j'intégrerai un correctif dans la version de Creme 2.6 qui sortira la semaine prochaine.
Bonne journée !
|