Skip to content

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.

License

Notifications You must be signed in to change notification settings

erfansafarzad7/Asyncio

Repository files navigation

Asyncio Python Examples

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.

🔥 Contents

  • 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_for for 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.Future and 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.Lock for synchronization between coroutines.
  • 09_bounded_semaphore.py - Demonstrates resource limiting using asyncio.BoundedSemaphore.
  • 10_event.py - Introduction to asyncio.Event for coroutine communication.
  • 11_condition.py - Explains asyncio.Condition for complex synchronization scenarios.
  • 12_subprocess.py - Demonstrates subprocess management using asyncio.create_subprocess_exec.
  • 13_aiohttp_module.py - Introduction to the aiohttp library for asynchronous HTTP requests.

📌 Requirements

  • Python 3.7+
  • Install dependencies:
    pip install aiohttp

⭐ Running the Examples

Run each script individually to see the corresponding concept in action:

  1. Clone the repository:

    git clone https://github.com/your-username/your-repo-name.git
  2. Navigate to the repository directory:

    cd your-repo-name
  3. Run any script using Python:

    python 01_coroutine.py

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch.
  3. Commit your changes.
  4. Submit a pull request.

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.


🔗 Connect with Me


Happy Coding! 🎉

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages