I've a serious problem I'm getting crazy to solve.
I wrote a basic python API with flask.
I run it with waitress, because if I do app.run()
it says that I should not do it because it supposed ok only for development not distribution.
This is the .py
from flask import Flask
from flask_restful import Api, Resource, reqparse, abort
from dotenv import load_dotenv
import DBLayer
import os
import socket
from datetime import datetime
from waitress import serve
load_dotenv()
db_host = os.getenv('DB_HOST')
db_user = os.getenv('DB_USER')
db_pwd = os.getenv('DB_PWD')
db_port = os.getenv('DB_PORT')
db_name = os.getenv('DB_NAME')
app = Flask(__name__)
api = Api(app)
class Version(Resource):
def get(self):
comando = "select * from versiondb"
version = DBLayer.executeSQL(db_user, db_pwd, db_host, db_name, db_port, comando)
dataAggiornamento = datetime.strptime(str(versione[0]["Validita"]), "%Y-%m-%d %H:%M:%S")
version[0].update({"Validita": str(dataAggiornamento)})
if len(version) == 0:
return "", 404
return {"data": dict(version[0])}, 200
api.add_resource(Version, "/version")
if __name__ == "__main__":
serve(app, host=myhost, port=5000)
I execute this .py on my Windows server, it works fine, but after sometimes I notice that the api is not responding anymore to the get request... so I open the Remote Desktop to take a look at what is happening... the terminal Is freezed.. I click with the mouse on the terminal, I press a random button on the keyboard, and all the request made from when it freezed to now are printed and executed in that instant, all at once... this is SO ANNOYNG
Someone can help me? please.
I found out that the same exact code on a Linux based server is getting no errors.
So... I assume (after doing some research on internet) that is a Windows related issue.