←back to thread

320 points willm | 1 comments | | HN request time: 0.381s | source
Show context
PaulHoule ◴[] No.45106346[source]
I went through a phase of writing asyncio servers for my side projects. Probably the most fun I had was writing things that were responsive in complex ways, such as a websockets server that was also listening on message queues or on a TCP connection to a Denon HEOS music player.

Eventually I wrote an "image sorter" that I found was hanging up when the browser was trying to download images in parallel, the image serving should not have been CPU bound, I was even using sendfile(), but I think other requests would hold up the CPU and would be block the tiny amount of CPU needed to set up that sendfile.

So I switched from aiohttp to the flask API and serve with either Flask or Gunicorn, I even front it with Microsoft IIS or nginx to handle the images so Python doesn't have to. It is a minor hassle because I develop on Windows so I have to run Gunicorn inside WSL2 but it works great and I don't have to think about server performance anymore.

replies(2): >>45106551 #>>45109325 #
1. Townley ◴[] No.45109325[source]
It’s heartening that there are people who find the problem you described “fun”

Writing a FastAPI websocket that reads from a redis pubsub is a documentation-less flailfest