I'm currently running an flask python application running on an NGINX server with the help of uWGI. The static pages are always reachable but the pages that use a connection (MySQL) time out after 2 minutes. What's going on? They become simply become unavailable.
Things I have tried:
- Not using a global
- working with pools
- turning off firewall
.
# using python version 2.7.10 from flask import Flask, jsonify, request, session import mysql.connector.pooling #Make a connection with the DB dbconfig = { "host" : "12.34.5.78", "database": "db", "user": "user", "password": "pass" } conn = mysql.connector.connect(pool_name = "mypool", pool_size = 6, **dbconfig) #Define the root app = Flask(__name__) #Landings page @app.route('/') def index(): return "Hello World." # return all resources by name @app.route('/resources', methods=['GET']) def allResourceNames(): conn1 = mysql.connector.connect(pool_name="mypool") reader = conn1.cursor() query = ("SELECT name FROM resources") reader.execute(query) resources = [] for name in reader: resources.append({'name' : name[0]}) reader.close() conn1.close() return jsonify({"resources" : resources}) if __name__ == "__main__": app.run(debug=True)