uWSGI request timeout in Python

You’re propably looking for the harakiri parameter – if request takes longer than specified harakiri time (in seconds), the request will be dropped and the corresponding worker recycled. For standalone uwsgi (ini config): [uwsgi] http = 0.0.0.0:80 harakiri = 30 … If you have nginx proxy before uwsgi you have to increase timeout as well: … Read more

Why is PyMongo 3 giving ServerSelectionTimeoutError?

We’re investigating this problem, tracked in PYTHON-961. You may be able to work around the issue by passing connect=False when creating instances of MongoClient. That defers background connection until the first database operation is attempted, avoiding what I suspect is a race condition between spin up of MongoClient’s monitor thread and multiprocess forking.

X-Forwarded-Proto and Flask

You are missing the ProxyFix() middleware component. See the Flask Proxy Setups documentation. There is no need to subclass anything; simply add this middleware component to your WSGI stack: # Werkzeug 0.15 and newer from werkzeug.middleware.proxy_fix import ProxyFix from flask import Flask app = Flask(__name__) app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1) If you have Flask installed, you … Read more

uWSGI, Flask, sqlalchemy, and postgres: SSL error: decryption failed or bad record mac

The issue ended up being uwsgi’s forking. When working with multiple processes with a master process, uwsgi initializes the application in the master process and then copies the application over to each worker process. The problem is if you open a database connection when initializing your application, you then have multiple processes sharing the same … Read more

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding, when trying to start uwsgi

I see your PYTHONHOME is set to PYTHONHOME = ‘/home/env3/educ’. Try to check if it is really there. The solution for me was to remove the PYTHONHOME environment variable. For you, it can be just that, or setting that variable to another value. This worked on Windows, and would work on Linux for sure. If … Read more

Flask application traceback doesn’t show up in server log

Run in development mode by setting the FLASK_ENV environment variable to development. Unhandled errors will show a stack trace in the terminal and the browser instead of a generic 500 error page. export FLASK_ENV=development # use `set` on Windows flask run Prior to Flask 1.0, use FLASK_DEBUG=1 instead. If you’re still using app.run (no longer … Read more