async.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:hacks 作者: neo1218 项目源码 文件源码
def run_ctx_request(environ):
    """
    run flask request context in celery worker
    """
    from blueprints import app  # wsgi.app

    if '_wsgi.input' in environ:
        # an input stream (file-like object) from which the HTTP request body can be read.
        # detail: https://www.python.org/dev/peps/pep-0333/#environ-variables
        environ['wsgi.input'] = BytesIO(environ['_wsgi.input'])

    with app.request_context():
        g.in_celery = True

        try:
            rv = app.full_dispatch_request()
        except InternalServerError:
            if app.debug:
                raise
            return app.make_response(InternalServerError())
        return (rv.get_data(), rv.status_code, rv.headers)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号