I have a flask endpoint with Gunicorn as the server. I containerized the app and deployed on an azure container instance.
It has been working fine but then this error started popping up when starting the container instance.
complete error traceback
from prometheus flask exporter.multiprocess import Gunicorn PrometheusMetrics
File "/usr/local/lib/python3.7/site-packages/prometheus_flask_exporter/__init__.py", line 12, in <module> from flask.views import MethodViewType
ImportError: cannot import name 'MethodViewType' from 'flask.views' (/usr/local/lib/python3.7/site-packages/flask/views.py) 2022-08-02T10:19:32.1978187Z
stderr F
The code looks like this
config.py
import os
from prometheus_flask_exporter.multiprocess import GunicornPrometheusMetrics
def when_ready(server):
GunicornPrometheusMetrics.start_http_server_when_ready(80)
def child_exit(server, worker):
GunicornPrometheusMetrics.mark_process_dead_on_child_exit(worker.pid)
app.py
from flask import Flask, Response, jsonify, request
from .errors import errors
from .middleware import *
from PIL import Image
import time
import io
import base64
import logging
import json
from logging.handlers import RotatingFileHandler
# from concurrent_log_handler import ConcurrentRotatingFileHandler
from azure_storage_logging.handlers import BlobStorageRotatingFileHandler
from prometheus_flask_exporter.multiprocess import GunicornPrometheusMetrics
import os
import warnings
warnings.filterwarnings("ignore")
logging.basicConfig(
handlers=[
# RotatingFileHandler('./ocr_log.log', maxBytes=100000),
BlobStorageRotatingFileHandler(filename=os.environ['filename'], maxBytes=100000,
container=os.environ['container_name'],
account_name=os.environ['storage_account_name'],
account_key=os.environ['storage_account_key']),
# ConcurrentRotatingFileHandler(filename='ocr_log_concurrent.log')
],
level=logging.INFO,
format=u"[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s",
datefmt='%Y-%m-%dT%H:%M:%S')
logging.captureWarnings(True)
logging.propagate = True
app = Flask(__name__)
app.register_blueprint(errors)
metrics = GunicornPrometheusMetrics(app)
metrics.info("app_info", "App Info, this can be anything you want", version="1.0.0")
I have a flask endpoint with Gunicorn as the server. I containerized the app and deployed on an azure container instance.
It has been working fine but then this error started popping up when starting the container instance.
complete error traceback
The code looks like this
config.py
app.py
gunicorn command