This repository contains practical examples and demonstrations of Python's asyncio module. Each script is designed to showcase different features and concepts of asynchronous programming in Python.
- 01_coroutine.py - Introduction to coroutines and basic async/await usage.
- 02_cancel_and_waitfor.py - Demonstrates how to cancel tasks and use
asyncio.wait_forfor timeout handling. - 03_shield.py - Protects a task from being canceled using
asyncio.shield. - 04_event_loop.py - Explains how the event loop works and how to manage it manually.
- 05_gather.py - Shows how to run multiple coroutines concurrently using
asyncio.gather. - 06_future.py - Introduction to
asyncio.Futureand how to use it for advanced task handling. - 07_wait.py - Demonstrates how to wait for multiple tasks to complete using
asyncio.wait. - 08_lock.py - Covers the use of
asyncio.Lockfor synchronization between coroutines. - 09_bounded_semaphore.py - Demonstrates resource limiting using
asyncio.BoundedSemaphore. - 10_event.py - Introduction to
asyncio.Eventfor coroutine communication. - 11_condition.py - Explains
asyncio.Conditionfor complex synchronization scenarios. - 12_subprocess.py - Demonstrates subprocess management using
asyncio.create_subprocess_exec. - 13_aiohttp_module.py - Introduction to the
aiohttplibrary for asynchronous HTTP requests.
- Python 3.7+
- Install dependencies:
pip install aiohttp
Run each script individually to see the corresponding concept in action:
-
Clone the repository:
git clone https://github.com/your-username/your-repo-name.git
-
Navigate to the repository directory:
cd your-repo-name -
Run any script using Python:
python 01_coroutine.py
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch.
- Commit your changes.
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- LinkedIn: Visit Profile
- Email: Send Me an Email
- Telegram: Send Me Message
Happy Coding! 🎉