Python Concurrency Patterns: Thread-Based vs. Async-Based Approaches

Farhaan Bukhsh (~farhaanbukhsh)


5

Votes

Description:

Introduction:

Python offers multiple concurrency approaches, each with its strengths and weaknesses. This talk aims to provide a comprehensive comparison between two popular concurrency patterns: Thread-Based and Async-Based approaches. Attendees will gain a deep understanding of the differences, advantages, and trade-offs between these patterns, enabling them to make informed decisions when designing concurrent Python applications.

Description:

Concurrency is crucial for efficiently handling multiple tasks and improving overall system performance. In Python, developers have two main concurrency patterns to choose from: Thread-Based Concurrency and Async-Based Concurrency. Both approaches enable concurrent execution of tasks, but they differ significantly in their design, execution model, and resource management.

In this talk, we will dive into the intricacies of these concurrency patterns, highlighting their distinct characteristics and exploring real-world scenarios where each approach shines. We'll examine the following key aspects:

  1. Overview of Thread-Based Concurrency:

    • Understanding Threads in Python: The threading module and its use cases. This will be demonstrated by showing examples and live programming.
    • Shared State and Locking: Managing shared resources and avoiding race conditions.
    • Global Interpreter Lock (GIL): Its impact on multithreading and performance considerations.
  2. Exploring Async-Based Concurrency:

    • Introduction to Asynchronous Programming: Asynchronous vs. Synchronous execution in Python.
    • The asyncio Library: Understanding event loops, coroutines, and async/await syntax and use cases.
    • Non-Blocking I/O: How async-based code enables efficient I/O-bound operations.
    • Benefits of Asynchronous Approach: Scalability, responsiveness, and resource utilization.
  3. Best Practices and Pitfalls:

    • Hybrid Approaches: Combining threads and async for specific use cases.
    • Debugging and Profiling: Tools and techniques for troubleshooting concurrency issues.
    • Maintaining Code Readability: Strategies for writing maintainable concurrent code.

By the end of the talk, attendees will have a clear understanding of when and how to use thread-based or async-based concurrency in Python based on their application requirements and workload characteristics. They will be equipped with practical knowledge to build scalable, responsive, and high-performance concurrent applications while avoiding common pitfalls associated with each concurrency pattern.

Prerequisites:

  • Basic Python
  • Interest in Programming Paradigm

Speaker Info:

Farhaan Bukhsh is a software engineer and core committer at OpenCraft, maintaining Open edX. With a strong focus on open source, he's contributed to Fedora projects and is passionate about Python, asynchronous programming, and e-learning platforms. As a speaker, he shares valuable insights on open-source collaboration and empowering developers to build innovative solutions. He recently co-founded Metamind.

Speaker Links:

Website: https://farhaan.me/

Blog: https://journal.farhaan.me/

LinkdIn https://www.linkedin.com/in/farhaanbukhsh/

Section: Concurrency
Type: Talks
Target Audience: Intermediate
Last Updated: