我收到这个错误。它发生在从前端的定期请求,以前的请求有响应200,但我的后端容器突然重新加载。以前它是工作和一切工作正常。
Django版本3.2.13 Python版本3.9云AWS
追溯:
Traceback (most recent call last):
File "/app/manage.py", line 21, in <module>
main()
File "/app/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 61, in execute
super().execute(*args, **options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 96, in handle
self.run(**options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 103, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 638, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 623, in start_django
reloader.run(django_main_thread)
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 329, in run
self.run_loop()
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 335, in run_loop
next(ticker)
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 375, in tick
for filepath, mtime in self.snapshot_files():
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 391, in snapshot_files
for file in self.watched_files():
File "/usr/local/lib/python3.9/site-packages/django/utils/autoreload.py", line 294, in watched_files
yield from directory.glob(pattern)
File "/usr/local/lib/python3.9/pathlib.py", line 1177, in glob
for p in selector.select_from(self):
File "/usr/local/lib/python3.9/pathlib.py", line 611, in _select_from
for p in successor_select(starting_point, is_dir, exists, scandir):
File "/usr/local/lib/python3.9/pathlib.py", line 558, in _select_from
with scandir(parent_path) as scandir_it:
FileNotFoundError: [Errno 2] No such file or directory: '/proc/393/task/558'
这是要求.txt:
aioredis==1.3.1
amqp==5.1.0
anyio==3.5.0
asgiref==3.5.0
async-timeout==4.0.2
attrs==21.4.0
autobahn==22.4.2
Automat==20.2.0
backports.zoneinfo==0.2.1
billiard==3.6.4.0
boto3==1.22.7
botocore==1.25.7
celery==5.2.6
certifi==2021.10.8
cffi==1.15.0
channels==3.0.4
channels-redis==3.4.0
charset-normalizer==2.0.12
click==8.1.2
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
colorama==0.4.4
constantly==15.1.0
coreapi==2.3.3
coreschema==0.0.4
cryptography==37.0.2
daphne==3.0.2
Deprecated==1.2.13
Django==3.2.13
django-celery-beat==2.2.1
django-cors-headers==3.11.0
django-debug-toolbar==3.2.4
django-filter==21.1
django-redis==5.2.0
django-ses==3.0.1
django-storages==1.13.1
django-timezone-field==4.2.3
djangorestframework==3.13.1
djangorestframework-simplejwt==5.1.0
drf-yasg2==1.19.4
et-xmlfile==1.1.0
h11==0.13.0
hiredis==2.0.0
httptools==0.4.0
hyperlink==21.0.0
idna==3.3
incremental==21.3.0
inflection==0.5.1
itypes==1.2.0
Jinja2==3.1.1
jmespath==1.0.0
kombu==5.2.4
MarkupSafe==2.1.1
msgpack==1.0.3
numpy==1.22.4
openpyxl==3.0.10
packaging==21.3
pandas==1.4.2
prompt-toolkit==3.0.29
psycopg2-binary==2.9.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
PyJWT==2.3.0
pyOpenSSL==22.0.0
pyparsing==3.0.8
python-crontab==2.6.0
python-dateutil==2.8.2
python-decouple==3.6
python-dotenv==0.20.0
pytz==2022.1
PyYAML==6.0
redis==4.2.2
requests==2.27.1
ruamel.yaml==0.17.21
ruamel.yaml.clib==0.2.6
s3transfer==0.5.2
sentry-sdk==1.5.10
service-identity==21.1.0
six==1.16.0
sniffio==1.2.0
sqlparse==0.4.2
stripe==2.73.0
Twisted==22.4.0
txaio==22.2.1
typing_extensions==4.2.0
uritemplate==4.1.1
urllib3==1.26.9
uvicorn==0.17.6
uvloop==0.16.0
vine==5.0.0
watchgod==0.8.2
wcwidth==0.2.5
websockets==10.3
wrapt==1.14.0
zope.interface==5.4.0
yearfrac==0.4.7
openpyxl==3.0.10
Pillow==9.2.0
这是docker-compose文件:
backend:
image: backend:latest
restart: always
container_name: backend
hostname: backend
env_file:
- ./.env
volumes:
- ./media:/app/media
- ./static:/app/static
command: bash -c "ls -la && python -u manage.py collectstatic --noinput && python -u manage.py migrate && python -u manage.py runserver 0.0.0.0:8000"
depends_on:
- redis
有什么想法和帮助吗?
1条答案
按热度按时间5cnsuln71#
我们在把项目升级到"django4"和"python3.8"时遇到了同样的问题。
我们花了几个星期的时间寻找可能的解决方案,发现我们的项目相当稳健;它有很多文件,而django默认的"自动重载"在这些情况下不够理想。
考虑在项目中安装watchman
文件: