A repo to show, keep and tinker with asynchronous execution in python. This repo is not to be used as something to build upon, but rather a folder of code snippets and resources, e.g. links, articles, videos etc. to show how to use concept, and easily snag for other projects.
- Using threading (when we have lots of I/O leading to idle CPU)
- Using asyncio (threading mad simple)
- Using multiprocessing (when we hav CPU-heavy calculations and several cores)
- .. (to come?)
The asynco io module requires python 3.7, and some features even 3.8 and beyond.
This is not a standalone code, but just a bag of code snippets and other artifacts helping anyone to get started with asynchronous execution of python code. Feel free to contribute with a pull request!
Make sure you have python3.7, or beyond where the 'asyncio' library is included.
Asyncio:
- Reading: https://docs.python.org/3/library/asyncio.html
- Watching: https://www.youtube.com/watch?v=bs9tlDFWWdQ&t=555s
Threading:
- Reading: https://docs.python.org/3/library/threading.html
- Watching: https://www.youtube.com/watch?v=IEEhzQoKtQU
Multiprocessing:
-
Reading: https://docs.python.org/3/library/multiprocessing.html
-
Sharing memory, and message passing (queue and pipe): https://www.geeksforgeeks.org/multiprocessing-python-set-2/
- To use just run any python file as a script, it should work. Let me know if it does not
No test have been set up for the examples.
Written by Johan Ludde Wessén jlwessen@kth.se, October 2021
🏛 Website: https://www.kth.se/profile/jlwessen