The #Python documentation has a nice "Hello World" example for async.
In this example, you see how to create an asynchronous function, sleep and print out some strings:
Just for fun, here's an example of what asynchronous functions looked like back in #Python 3.4
They were explicitly called coroutines and used a decorator rather than the `async def` keywords:
I attempted to learn how to use async calls with #Python a few years ago. Here is an example of scheduling calls to functions using async using the `call_soon()` method.
`call_soon()` calls your function "as soon as it can" using a FIFO queue
The asyncio example in the previous tweet comes from one of my articles @mousevspython here:
Concurrency is a hard topic. So today we're going to talk about multiprocessing in #Python
Join for me another fun mini-thread!
๐งต๐๐
The Pros of using `multiprocessing` in #Python (part 1 of 2)
๐ Processes use separate memory space
๐ Code can be more straightforward compared to threads
๐ Uses multiple CPUs / cores
๐ Avoids the Global Interpreter Lock (GIL)
The Pros of using `multiprocessing` in #Python (part 2 of 2)
๐ Child processes can be killed (unlike threads)
๐ The multiprocessing module has an interface similar to `threading.Thread`
๐ Good for CPU-bound processing (encryption, binary search, matrix multiplication)