Проблема с развертыванием приложения Flask с Apache (mod_wsgi) — продолжает загружаться

#python #apache #flask #mod-wsgi

Вопрос:

У меня возникли проблемы с развертыванием приложения flask. Приложение продолжает загружаться без явных ошибок msg в журналах Apache.

Любая помощь будет очень признательна !

То есть:

 [Thu Oct 07 15:31:14.540716 2021] [mpm_winnt:notice] [pid 19000:tid 928] AH00362: Child: Waiting 30 more seconds for 1 worker threads to finish.
[Thu Oct 07 15:31:47.366729 2021] [mpm_winnt:notice] [pid 19000:tid 928] AH00362: Child: Waiting 0 more seconds for 1 worker threads to finish.
[Thu Oct 07 15:31:47.476088 2021] [mpm_winnt:notice] [pid 19000:tid 928] AH00363: Child: Terminating 1 threads that failed to exit.
[Thu Oct 07 15:31:47.476088 2021] [mpm_winnt:notice] [pid 19000:tid 928] AH00364: Child: All worker threads have exited.
[Thu Oct 07 15:43:14.638219 2021] [mpm_winnt:notice] [pid 14968:tid 876] AH00422: Parent: Received shutdown signal -- Shutting down the server.
 

Мне интересно, связано ли это с использованием заводской функции (потому что при тестировании с помощью простого примера приложения Flask это работает !).

Вот упрощенный вид моего приложения:

 <chart-publisher>
|
| --publisher
|     |-- __init__.py
|     |-- highcharts_bp.py
|     |-- converter.py
|     |-- ..
| -- publisher.wsgi
 

init.py:

 from flask import Flask
from flask_cors import CORS
from datetime import timedelta
from flask_session.__init__ import Session


def create_app(test_config=None):
    app = Flask(__name__)
    CORS(app)  # to avoid cross origin requests

    app.config['UPLOAD_FOLDER'] = '..\out\uploaded'
    app.config['HTML_OUT_FOLDER'] = '..\out\html'
    app.config['ALLOWED_FILES'] = ['xls', 'xlsx', 'xlsm']

    app.config['SESSION_TYPE'] = 'filesystem'
    app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(hours=1)
    app.config['SECRET_KEY'] = 'mysecretkey'
    app.config.from_object(__name__)
    Session(app)

    from publisher.highcharts_bp import bp
    app.register_blueprint(bp)

    app.add_url_rule('/', endpoint='index')

    return app
 

издатель.wsgi:

 import sys
sys.path.insert(0, r'C:Users<user>Devchart-publisher')

from publisher import create_app
application = create_app()
 

httpd.conf:

 LoadFile "c:/users/<user>/miniconda3/python38.dll"
LoadModule wsgi_module "c:/users/<user>/miniconda3/lib/site-packages/mod_wsgi/server/mod_wsgi.cp38-win_amd64.pyd"
WSGIPythonHome "c:/users/<user>/miniconda3"

<VirtualHost *:81>
    ServerName localhost
    WSGIScriptAlias / C:Users<user>Devchart-publisherpublisher.wsgi
    ErrorLog "C:ApacheApache24logserror.log"
    <Directory "C:/Users/<user>/Dev/chart-publisher">
        Require all granted 
    </Directory>
</VirtualHost>
 

EDIT:

After investigating, I managed to isolate an import issue, but still not sure why this doesnt work. By commenting out the following imports in converter.py:

 # import xlwings as xw
# import pandas as pd
# from colormap import rgb2hex
 

The app is deployed and running (but non-functionnal / would crash).
Any idea what could cause those imports to fail ?

highcharts_bp.py:

 ...
import publisher.converter as conv
..
 

converter.py

 ..
import xlwings as xw
import pandas as pd
from colormap import rgb2hex
..