简体   繁体   中英

Apache2&Django - NameError: name “AttributeError” is not defined

I followed pretty much every official documentation to get my Django project running on my Ubuntu 18.04 v-server. And it seems to work...sudo service apache2 status -> everything ok too.

[Sun May 03 16:07:20.489608 2020] [mpm_event:notice] [pid 11531:tid 139884218760128] AH00489: 
Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 mod_wsgi/4.7.1 Python/3.8 configured -- resuming normal operations

[Sun May 03 16:07:20.489764 2020] [core:notice] [pid 11531:tid 139884218760128] AH00094:
Command line: '/usr/sbin/apache2'

I first noticed that something's off when my templates wouldn't update without a server restart which is not Django's usual behaviour (even in a productive environment). Whenever I restart the server I get this error in the apache2/error.log. Although the server keeps working I want to get to the bottom of this.

Exception ignored in: <function Local.__del__ at 0x7fbd983f03a0>
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 0x7fbd983f03a0>
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
[Sun May 03 16:07:19.418926 2020] [core:warn] [pid 11433:tid 140452536064960] AH00045: child process 11435 still did not exit, sending a SIGTERM
[Sun May 03 16:07:20.419208 2020] [mpm_event:notice] [pid 11433:tid 140452536064960] AH00491: caught SIGTERM, shutting down
[Sun May 03 16:07:20.489608 2020] [mpm_event:notice] [pid 11531:tid 139884218760128] AH00489: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 mod_wsgi/4.7.1 Python/3.8 configured -- resuming normal operations
[Sun May 03 16:07:20.489764 2020] [core:notice] [pid 11531:tid 139884218760128] AH00094: Command line: '/usr/sbin/apache2'
  • Ubuntu 18.04
  • Python3.8.0 and linked to the python-command via update-alternatives
  • Python running in venv

Project-structure:

in /var/www/:
    |-- my_app
    |   |-- my_app
    |   |   |-- __init__.py
    |   |   |-- asgi.py
    |   |   |-- settings.py
    |   |   |-- urls.py
    |   |   `-- wsgi.py
    |   |-- db.sqlite3
    |   |-- manage.py
    |   |-- media
    |   |-- .my_app (python venv)
    |   |-- my_subapp
    |   |   |-- __init__.py
    |   |   |-- admin.py
    |   |   |-- apps.py
    |   |   |-- migrations
    |   |   |-- models.py
    |   |   |-- tests.py
    |   |   |-- urls.py
    |   |   `-- views.py
    |   `-- templates
    |       |-- base.html
    |       `-- index.html

Any suggestions what could be wrong and why it says "AttributeError not found?" when it seems to be a standard python class that ship with it out of the box... Thank you for your help:-)

It took me a day to find out what the issue was - Thanks to Graham Dumpleton - the creator of the mod_wsgi for explaining everything. You can look it up here:

https://github.com/GrahamDumpleton/mod_wsgi/issues/568

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM