mod_wsgi: NameError when importing Django templates folder

I want to link to my initial issue submit at the asgiref module because I thought it was a problem on that side. Well, I’m not sure where it is… For some more comments see this: https://github.com/django/asgiref/issues/157

Summary what I did:

  • new Linux install with Ubuntu 18.04, sudo apt-get install python3.8 python3.8-venv
  • installed mod_wsgi in accord with the docs
  • started a new Django project with a dedicated venv and everything worked fine up to the point where I introduce a project-wide template folder and point to it in the settings.py

Insert this:

TEMPLATES = [
    {
        ...
        'DIRS': [os.path.join(BASE_DIR,'templates'),],
        ....

    },
]

Then I get this:

[Tue May 05 19:57:52.653410 2020] [mpm_event:notice] [pid 10734:tid 140655679445952] AH00491: caught SIGTERM, shutting down

Exception ignored in: <function Local.__del__ at 0x7fece48a09d0>
Traceback (most recent call last):
  File "/var/www/my_app/.my_app/lib/python3.8/site-packages/asgiref/local.py", line 95, in __del__
NameError: name 'AttributeError' is not defined
Exception ignored in: <function Local.__del__ at 0x7fece48a09d0>
Traceback (most recent call last):
  File "/var/www/my_app/.my_app/lib/python3.8/site-packages/asgiref/local.py", line 95, in __del__
NameError: name 'AttributeError' is not defined

[Tue May 05 19:57:52.815381 2020] [mpm_event:notice] [pid 11050:tid 140050920782784] AH00489: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 mod_wsgi/4.7.1 Python/3.8 configured -- resuming normal operations

[Tue May 05 19:57:52.815626 2020] [core:notice] [pid 11050:tid 140050920782784] AH00094: Command line: '/usr/sbin/apache2

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

@arruda33 If Apache processes are getting shutdown at random times per day, then you may be using embedded mode rather than daemon mode. Not possible to tell unless you provide the mod_wsgi configuration. Also ensure log level is set to info so can see details about what processes are being shutdown and why.

Another reason processes may be getting shutdown is your Apache processes are using too much memory and the Linux OOM killer is deciding to kill them off.