当我向网络服务器发出请求时,所有其他响应将是500错误。
错误是:
Traceback (most recent call last): file "/var/env/argos/lib/python3.3/site-packages/sqlalchemy/engine/base.py",line 867,in _execute_context context) file "/var/env/argos/lib/python3.3/site-packages/sqlalchemy/engine/default.py",line 388,in do_execute cursor.execute(statement,parameters)psycopg2.OperationalError: SSL error: decryption Failed or bad record macThe above exception was the direct cause of the following exception:sqlalchemy.exc.OperationalError: (OperationalError) SSL error: decryption Failed or bad record mac
该错误由简单的Flask-sqlAlchemy方法触发:
result = models.Event.query.get(ID)
uwsgi由管理员管理,它有一个配置:
[program:my_app]command=/usr/bin/uwsgi --ini /etc/uwsgi/apps-enabled/myapp.ini --catch-exceptionsdirectory=/path/to/my/appstopsignal=QUITautostart=trueautorestart=true
和uwsgi的配置看起来像:
[uwsgi]socket = /tmp/my_app.socklogto = /var/log/my_app.logplugins = python3virtualenv = /path/to/my/venvpythonpath = /path/to/my/appwsgi-file = /path/to/my/app/application.pycallable = appmax-requests = 1000chmod-socket = 666chown-socket = www-data:www-datamaster = trueprocesses = 2no-orphans = truelog-date = trueuID = www-datagID = www-data
我可以得到的最远的是它与uwsgi的分叉有关。但除此之外,我还不清楚需要做些什么。
这个问题最终是uwsgi的问题。当使用主进程处理多个进程时,uwsgi将在主进程中初始化应用程序,然后将应用程序复制到每个工作进程。问题是如果您在初始化应用程序时打开数据库连接,则会有多个进程共享相同的连接,从而导致上述错误。
解决方案是设置懒惰configuration option for uwsgi,这迫使应用程序在每个进程中完全加载:
lazy
Set lazy mode (load apps in workers instead of master).
This option may have memory usage implications as copy-on-Write semantics can not be used. When lazy is enabled,only workers will be reloaded by uWsgi’s reload signals; the master will remain alive. As such,uWsgi configuration changes are not picked up on reload by the master.
还有一个懒惰应用程序选项:
lazy-apps
Load apps in each worker instead of the master.
This option may have memory usage implications as copy-on-Write semantics can not be used. Unlike lazy,this only affects the way applications are loaded,not master’s behavior on reload.
这个uwsgi配置最终为我工作:
[uwsgi]socket = /tmp/my_app.socklogto = /var/log/my_app.logplugins = python3virtualenv = /path/to/my/venvpythonpath = /path/to/my/appwsgi-file = /path/to/my/app/application.pycallable = appmax-requests = 1000chmod-socket = 666chown-socket = www-data:www-datamaster = trueprocesses = 2no-orphans = truelog-date = trueuID = www-datagID = www-data# the fixlazy = truelazy-apps = true总结
以上是内存溢出为你收集整理的postgresql – uWSGI,Flask,sqlalchemy和postgres:SSL错误:解密失败或坏记录mac全部内容,希望文章能够帮你解决postgresql – uWSGI,Flask,sqlalchemy和postgres:SSL错误:解密失败或坏记录mac所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)