Django not Working in ASGI app in second/defferent process

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. ProcessusingAsyncServerandASGIApp. The problem is that Django works with Sync functions like get()orcreate(), but if we use aget()oracreate()` 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.

Back to Top