RuntimeError: populate() isn't reentrant

Describe the bug
Cyberpanel admin panel returns 500 internal server error error page. After upgrading, everything works for a while (couple days, weeks) and then again, returns 500 internal server error error page.

To Reproduce
What steps did you take when the issue occurred?

  1. Upgraded to latest build and commit using sudo su - -c "sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh || wget -O - https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh);
  2. Do nothing (wait couple days.. or weeks);
  3. 500 internal server error error page appears in Cyberpanel admin panel;

Expected behavior
To return Cyberpanel admin panel page (successful).

Screenshots
Image

Operating system:
Ubuntu 22.04.5 LTS

CyberPanel version:
version v2.3.9, commit: 33cc6ba1dad4b805767a794ac79b4f3c144adea8

Additional context
After investigating/tailing tail -f /home/cyberpanel/stderr.log error log file and refreshing the page, I got the following error:

Traceback (most recent call last):
  File "/usr/local/CyberCP/CyberCP/wsgi.py", line 17, in <module>
    application = get_wsgi_application()
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/apps/registry.py", line 83, in populate
    raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant

After some research, I followed this suggestion to debug the error: https://stackoverflow.com/a/55929118/1097415. What I did was:

  1. I opened up /usr/local/CyberCP/lib/python3.10/site-packages/django/apps/registry.py line 83, commented out raise RuntimeError("populate() isn't reentrant") and replaced it with self.app_configs = {};
  2. Then I started tailing /home/cyberpanel/stderr.logagain withtail -f /home/cyberpanel/stderr.logand restarted Cyberpanelsystemctl restart lscpd.service` and refreshed the admin panel page;

Now, when inspecting error log, I finally found the issue:

Traceback (most recent call last):
  File "/usr/local/CyberCP/CyberCP/wsgi.py", line 17, in <module>
    application = get_wsgi_application()
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/CyberCP/lib/python3.10/site-packages/django/apps/registry.py", line 125, in populate
    app_config.ready()
  File "/usr/local/CyberCP/configservercsf/apps.py", line 10, in ready
    import signals
ModuleNotFoundError: No module named 'signals'

:backhand_index_pointing_right: Longstoryshort - No module named 'signals' in file /usr/local/CyberCP/configservercsf/apps.py is the issue.

:link: Here is the Cyberpanel GitHub issue link: https://github.com/usmannasir/cyberpanel/issues/1423

Try this fix.

1 Like

I also had another error after upgrading which is not related to csf.
So in case you also run into this issue after the csf fix.

2.3.9
Almalinux 9

To fix:

python3 -m pip install psutil==5.9.1
service lscpd restart

It seems that Cyberpanel is not specifying a version for psutil in their requirements.txt and so it’s installing version 7.0.0 which does not contain ā€œgetpagesizeā€.

AttributeError: module ā€˜psutil._psutil_posix’ has no attribute ā€˜getpagesize’

The fix downgrades psutil to a version that’s compatible

1 Like

As always, your contribution in debugging these type of bugs saves the day. <3 I will try this on two servers, if all is good for at least a month and next upgrade, I’ll try to create a PR for this.

P.S. Not gonna lie - this csf iframe integration should be a temporary fix. Plus, saving configuration just throws error page as well.

UPDATE
Your fix worked and I’ve submited it to issues ( :backhand_index_pointing_right: [BUG] RuntimeError: populate() isn't reentrant Ā· Issue #1423 Ā· usmannasir/cyberpanel Ā· GitHub) as well. Let’s hope it gets fixed in next upgrade. Thanks again.

This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.