3 ms·
asyncio has always looked interesting, but whenever I have run into a problem which could use asyncio I have always gone with multiprocesses instead. I am not s
by belorn 28d ago
asyncio has always looked interesting, but whenever I have run into a problem which could use asyncio I have always gone with multiprocesses instead. I am not sure if async would makes my code easier for others to read and debug, and none of my problems seems to be of the kind where process overhead would make a noticeable difference in performance.
Did you find readability to be improved by going async?
- LtWorf 27d agoI mean… if you have unlimited resources and unlimited speed, going multiprocess makes complete sense.
- nlitened 27d agoBut if you don’t, you don’t use Python anyway
- LtWorf 27d agoMaybe you have finite time to do the implementation and your task is IO bound? (which is where using async makes sense, by the way)
- belorn 26d agoLets make a specific example. You have an APIs to services with data that you want to synchronize to a cache in a local database. The providers allows a maximum of 1-3 connections for each api. You can write this in async with a pool of connections to each provider, or you can have a pool of worker processes that each have one connection to each provider. Which will be easier to debug, and which design is easier for the next developer to read, understand and modify? Performance wise the wast majority for both designs will be on waiting at the initial connections to the apis and time spent fetching objects.
- LtWorf 26d agoNow let's change the example but bump the limit to 3000 connections.
- belorn 26d agoAnd if the there were 3000, 30000 or 300000 providers the problem would be different. The example I gave was one where I have considered async but went with multiprocessing, which is also why I asked the parent commenter above if they found any direct benefit to readability or debugging when going async. It would be interesting to hear what kind of domain are you working in where you have 3000 simulations connections to different service providers.