hi, dear. i have a confusion about multiprocess and asyncio in sanic.
below are simplified code , workers=2:
from sanic import Sanic
app = Sanic("test")
@app.get("/video_stream")
async def hello_world(request):
response = await request.respond()
await mjpeg(response)
async def mjpeg(response):
...
# condition 2: await asyncio.sleep(0.01)
await response.write(...)
if __name__ == "__main__":
app.run(workers=2)
-
I try to open 4 video_stream:
only 2 run successful respectively in (SpawnProcess-0,SpawnProcess-1) ,
the other 2 video_stream are unreachable . -
I add
await asyncio.sleep(0.01)
in mjpeg and try to open 4 video_stream:
all 4 video_stream will run successful , but all in one process !
how can i balance it?