79282185

Date: 2024-12-15 11:01:04
Score: 7 🚩
Natty:
Report link

Have you solved it yet? I'm facing a similar problem. 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.

Reasons:
  • Blacklisted phrase (1): any help
  • Blacklisted phrase (2): Have you solved it
  • RegEx Blacklisted phrase (1.5): solved it yet?
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): I'm facing a similar problem
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Mohammad Mahdi Samei