Django如何避免多个进程对同一个请求运行同一个视图?

2024-10-03 11:24:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用AWS弹性Beanstalk部署了一个Django应用程序。在

Django有时由两个不同的视图执行。 这些情况会导致问题:例如,在文件上载期间,同一个文件存储了两次。在

我认为这个问题是由于autoreload选项造成的。对吗? 我该怎么解决这个问题?在

更新: 以下是我的配置文件:

container_commands:
  01_migrate:
    command: "django-admin.py migrate"
    leader_only: true
  02_createsu:
    command: "source /opt/python/run/venv/bin/activate && python manage.py createsu"
    leader_only: true
  03_update_permissions:
    command: "source /opt/python/run/venv/bin/activate && python manage.py update_permissions"
    leader_only: true
  04_collectstatic:
    command: "django-admin.py collectstatic --noinput"

option_settings:
  aws:elasticbeanstalk:application:environment:
    DJANGO_SETTINGS_MODULE: "olemshoe.settings_production"
  aws:elasticbeanstalk:container:python:
    WSGIPath: olemshoe/wsgi.py
    NumProcesses: 3
    NumThreads: 20
  aws:elasticbeanstalk:container:python:staticfiles:
    "/static/": "static/"

我应该将NumProcesses设置为1吗?在


Tags: 文件djangopyawstruesourceonlyadmin