- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想做以下事情:
r = requests.post('https://foo.com/test', data=json.dumps(fields), headers=headers)
if r.status_code != requests.codes.ok:
start_response(str(r.status_code) + ' ' + r.reason, [('Content-Type', 'text/plain')])
body.put(r.reason)
else:
start_response('200 OK', [('Content-Type', 'application/json')])
body.put(r.json())
但是这个调用会阻塞主线程,所以我这样做:
body = queue.Queue()
gevent.spawn(make_request, environ, start_response, body)
但现在我收到错误SystemError: you can call uwsgi api function only from the main callable
那么,如何将 start_response 的结果延迟到 POST 请求完成之后呢?
最佳答案
继续阻塞线程 —— 只用其中的几个来启动 uWSGI:
uwsgi --http :9090 --wsgi-file foobar.py --master --processes 4 --threads 2
来自 https://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html#adding-concurrency-and-monitoring
关于python - 如何延迟 uwsgi 中的 start_response?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25454095/
你能提供一个现实生活中的例子吗 WSGI start_response功能? (网络服务器为 wsgi 应用程序提供该功能) 我不明白引入start_response的目的。 (我读过大约 10 篇关
我编辑了我的问题,因为我意识到我正在结合两个概念(WSGIHandler 和中间件)我不应该在这个问题中结合起来。 我试图对 WSGIHandler 的作用有一些基本的了解。 django.core.
我想做以下事情: r = requests.post('https://foo.com/test', data=json.dumps(fields), headers=headers) if r.st
我有 WSGI 中间件需要捕获中间件内层通过调用 start_response 返回的 HTTP 状态(例如 200 OK)。目前我正在做以下事情,但滥用列表对我来说似乎不是“正确”的解决方案: cl
非 WSGI 方式: def my_view(request): request.start_response('200 OK') request.send_header('Conte
我是一名优秀的程序员,十分优秀!