zoukankan      html  css  js  c++  java
  • django channel 常见报错

    背景

    项目投产前准备步骤

    1.新建虚拟环境

    2.安装nginx 配置wsgi

    3.启动应用服务器(建议80/443)端口

    4.配置web服务器

    5.配置域名

     

    django took too long to shut down and was killed 报错

    症状:

    项目可以正常启动,每次只能处理一个请求,启动的服务很容易卡死

    attributeerror 'inmemorychannelayer' object has no attribute 'get'  报错

    症状:

    向数据库新增数据的时候提示 attributeerror 'inmemorychannelayer' object has no attribute 'get'

    解决方案

    运行环境

    python3.7

    pip==19.0.3  必须使用这个版本

    django==3.1.3

    channels==2.2.0 如果pip版本大于20的时候,安装channels会导致django 自动降级到2.1版本

    channels-redis==2.3.3

    settings.py 配置

    redis 集群配置 

    其它配置请参照官网:https://channels.readthedocs.io/en/stable/topics/channel_layers.html

    CACHES = {
        'default': {
            'BACKEND': 'django_redis.cache.RedisCache',
            'LOCATION': [
                "redis://127.0.0.1:6379/0",
                "redis://127.0.0.1:6380/0",
                "redis://127.0.0.1:6381/0",
            ],
            'OPTIONS': {
                'REDIS_CLIENT_CLASS': 'rediscluster.RedisCluster',
                'CONNECTION_POOL_CLASS': 'rediscluster.connection.ClusterConnectionPool',
                # 'CONNECTION_POOL_KWARGS': {
                #    'skip_full_coverage_check': True
                # }
            }
        }
    }
    CHANNEL_LAYERS = {
        "default": {
            "BACKEND": "channels.layers.InMemoryChannelLayer"
        }
    }

      

  • 相关阅读:
    php面向对象开发的学习
    我的php感悟
    说说面向对象
    session,上传文件
    PHP构造函数的用法分析
    生成图片
    上传文件
    fetch
    ajax2
    ajax1
  • 原文地址:https://www.cnblogs.com/wangcongxing/p/14250005.html
Copyright © 2011-2022 走看看