Replies: 1 comment 8 replies
-
因为PyWebIO是将会话的状态保存在进程中,所以,如果多进程部署,会导致请求被路由到错误的进程。 如果确实需要多进程部署来提高并发,可以使用 fastapi + uvicron 来部署,因为使用fastapi作为后端server时,是使用的websocket进行通信的,一个连接只会分配到同一个进程上 |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
作者你好。
背景
Django + uWSGI 多进程部署,函数内有
put_buttons()
且末尾加了pywebio.session.hold()
。期望
点击页面的
button
可以跟服务器交互,而不是提示「已断开连接」。现状
单独用 Django 的
runserver
在本地测试,一切正常,因为已经加了hold()
,该页面会每隔 1s 请求后台保持连接。用
uWSGI
多进程部署后,该页面几秒内
点击 button 有响应,之后就提示「已断开连接」。请问作者这种情况有办法解决吗?
部署文档好像没提到 uWSGI 之类的问题,FAQ 好像也没提到。
https://pywebio.readthedocs.io/zh_CN/latest/FAQ.html#why-the-callback-of-put-buttons-does-not-work
感谢~🙏
Beta Was this translation helpful? Give feedback.
All reactions