admin管理员组文章数量:1426957
I have Django and FastAPI on process#1, and they work in Sync and Async functions with no problem. I am running the SocketIO app in process#2 with multiprocessing
. Process
using AsyncServer
and ASGIApp
.
The problem is that Django works with Sync functions like get()
or create()
, but if we use aget()
or acreate()
the process disappears and vanishes. The rest of the line never runs with no error.
self.sio = socketio.AsyncServer(
async_mode="aiohttp",
cors_allowed_origins=self.socket_config.cors_allowed_origins,
always_connect=self.socket_config.always_connect,
logger=self.logger if self.socket_config.logger else False,
engineio_logger=self.logger if self.socket_config.engineio_logger else False,
)
self.socket_application = socketio.ASGIApp(self.sio, socketio_path=self.socket_config.socketio_path)
and run it with uvicorn
with pro
multiprocessing.Process(
target=uvicorn.run,
kwargs={
"app": "0.0.0.0",
"host": 8002,
"port": int(service_config.SERVICE_PORT),
},
daemon=True
).start()
I have tried to add get_asgi_application()
into other_asgi_app
of socketio.ASGIApp
but nothing changed.
I think the problem isn't from the Django setting with async permissions, it is between the ASGIApp and Django.
When it logged the self.socket_application
from ASGIApp
something interesting showed up, ...DjangoDBProcessRemove object ...
.
I would be looking forward to any help.
Update: If I run the SocketIO application in the main process works just fine. So I did. SocketIO in the main process and FastAPI in the Second with multiprocess, This time FastAPI faced this issue.
本文标签: socketioDjango not Working in ASGI app in seconddifferent processStack Overflow
版权声明:本文标题:socket.io - Django not Working in ASGI app in seconddifferent process - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745451172a2658892.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论