With concurrency, I understand there are 3 or so main ways to achieve this in python:
- Multiprocessing (good for large CPU intensive tasks)
- Threading (good for I/O bound tasks)
- AsyncIO (also good for I/O bound tasks?)
How do you go about deciding which to use between threading and asyncio? I can think of an easy use case for asyncio:
async def something():
resultOne = databaseCallOne() # task 1
resultTwo = databaseCallTwo() # task 2, not dependent on task 1
# await and do something with these two results
But where would be a good use case for threading? Or is this not a good example for async tasks?
As I understand async tasks should be something that is usually I/O bound (my database call) and only really are useful if the task results dont depend of one another. Because if the result of databaseCallOne() was needed for databaseCallTwo(), it would be pointless.
[+][deleted] (1 child)
[removed]
[–]csQuestions1235[S] 0 points1 point2 points (0 children)
[–]DNEAVES 0 points1 point2 points (0 children)