celery调试
celery启动代码
celery_worker.py如下:
from app import create_app from flask_celery import Celery app = create_app() celery = Celery(app) if __name__ == '__main__': celery.start()
运行配置
启动调试
点击PyCharm右上角的debug按钮
gunicorn调试
启动代码
在项目根目录下新建gapp.py,写入以下代码:
import multiprocessing from gunicorn.app.base import BaseApplication from app import create_app class GunicornApplication(BaseApplication): def __init__(self, app, options=None): self.options = options or {
} self.application = app super().__init__() def load_config(self): config = {
key: value for key, value in self.options.items() if key in self.cfg.settings and value is not None } for key, value in config.items(): self.cfg.set(key.lower(), value) def load(self): return self.application app = create_app() if __name__ == '__main__': gunicorn_options = {
'bind': '0.0.0.0:5000', 'workers': (multiprocessing.cpu_count() * 2) + 1, 'worker_class': 'gevent' } GunicornApplication(app, gunicorn_options).run()
兼容协程配置
启动调试
在gapp.py文件上点击右键,选择debug ‘gapp’开始调试程序
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/174052.html原文链接:https://javaforall.net
