Tom Ritchford
1 min readAug 14, 2023

--

Oh, I thought the writer was pretty clear.

If you have blocking, low-CPU processes like networks or spinning disks, then you have two choices: threads, or async.

Threads are easy to use and understand, because they are old technology and we have a lot of good examples.

Async is considerably harder to reason about for most of us.

And also, as the article points out, a lot of async implementations use threads behind the scenes.

Another reason which is not mentioned by the article is that if you use a thread-safe queue for your thread concurrency, then porting your code to multiprocessing might be as simple a matter of making sure the items that go into the queue are picklable or written into shared memory, and certainly your underlying structure can stay exactly the same.

Using multiprocessing is one effective way to use all the cores of your machine from a single program.

But there is no path to multiprocessing from async...

--

--

Responses (1)