Cademy logoCademy Marketplace

Course Images

Concurrent and Parallel Programming in Python

Concurrent and Parallel Programming in Python

🔥 Limited Time Offer 🔥

Get a 10% discount on your first order when you use this promo code at checkout: MAY24BAN3X

  • 30 Day Money Back Guarantee
  • Completion Certificate
  • 24/7 Technical Support

Highlights

  • On-Demand course

  • 6 hours 7 minutes

  • All levels

Description

This intermediate-level course will help you learn how to use multi-threading and asynchronous programming to speed up programs that are heavily bottlenecked by IO operations. The course covers core concepts such as implementing multiprocessing in Python, creating various readers and schedulers, and monitoring your coding progress.

In a big data project, a plethora of information is retrieved, big numbers are crunched on our machine, or both. If the coding is sequential or synchronous, our application will struggle to execute. Two mechanisms to alleviate such bottlenecks are concurrency and parallelism. In Python, concurrency is represented by threading, whereas multiprocessing achieves parallelism. This course begins with an introduction about potential programming speed bottlenecks and solving them. You will delve into Python concepts and create a Wikipedia Reader, Yahoo Finance Reader, Queues, and Master Scheduler. You will build a multi-threaded program to grab data from the Internet and parse and save them into a local database. Implement multiprocessing in Python, which lets us use multiple CPUs in our code. Learn about threading, multiprocessing, asynchronous wait, locking, multiprocessing queues, Pool Map Multiple Arguments, writing asynchronous programs, and combining async and multiprocessing. Upon completion, we can spread our workload over all cores available on the used machine. We will combine both elements, multiprocessing with asynchronous programming, to maximize benefit and CPU resource usage and minimize the time spent waiting for IO responses. You will create multi-threaded, asynchronous, multi-process programs to make programs run faster. All resources are available at: https://github.com/PacktPublishing/Concurrent-and-Parallel-Programming-in-Python

What You Will Learn

Learn to use concurrency and parallelism in Python
Write multi-threaded programs in Python to reduce coding lengths
Write multi-process programs that execute even faster
Understand the differences between concurrency and parallelism
Create asynchronous programs in Python by adding concurrency
Spread workload over all the cores available on a machine being used

Audience

This course is aimed at intermediate- to mastery-level seeking programmers, API developers, web developers, and application developers who know basic- to intermediate-level Python coding beforehand. The topics on concurrency and parallelism expect one to be aware of basic to intermediate understanding of coding on Python. Prior knowledge of basic Python coding is desirable for optimal benefit from this course.

Approach

The author delivers the courses in an online classroom format using high-quality onscreen video lectures and PowerPoint presentations. Each class begins with a quick refresher to the previously learned topic followed by an engaging and interactive video session and a summarization at the end of each lecture, thus enabling the learner to hone their skillsets learned efficiently.

Key Features

Understand where potential computing speed bottlenecks arise and how we can resolve them * Create multi-threaded, asynchronous, and multi-process programs to make your programs run faster * Combine multiprocessing with asynchronous programming to get maximum benefits of coding

Github Repo

https://github.com/PacktPublishing/Concurrent-and-Parallel-Programming-in-Python

About the Author

Maximilian Schallwig

Maximilian Schallwig is a data engineer and a proficient Python programmer. He holds a bachelor's degree in physics and a master's degree in astrophysics. He has been working on data for over five years, first as a data scientist and then as a data engineer. He can talk endlessly about big data pipelines, data infrastructure, and his unwavering devotion to Python. Even after two unsuccessful attempts in high school, he still decided to learn Python at the University. He cautiously stepped into the realm of data, beginning with a simple Google search for 'what does a data scientist do'. He was determined to pursue a career in data science to become a data engineer by learning about big data tools and infrastructure design to build scalable systems and pipelines. He enjoys sharing his programming skills with the rest of the world.

Course Outline

1. Threading

This section focuses on concurrency, and we will get introduced to threading, multiprocessing, and asynchronous coding. You will also learn to create threading classes, different kinds of readers and schedulers, and monitor our coding progress.

1. Threading, Multiprocessing, Async Introduction

In this video, we will be introduced to threading, multiprocessing, and asynchronous programs and the different considerations of choosing Python for coding.

2. Threading in Python

This lecture demonstrates how to write our first concurrent program. The author also explains the benefits of choosing the Python coding portal instead of the other code-writing portals.

3. Creating a Threading Class

After learning how to write our first threading program, you will learn how to use classes as our threading tools.

4. Creating a Wikipedia Reader

After comprehensively practicing our basic threading creation, we will look at the project we will create to implement threading more effectively.

5. Creating a Yahoo Finance Reader

After learning how to create the Wikipedia reader, you will learn how to write a threaded class to extract the price from a Yahoo Finance portal.

6. Queues and Master Scheduler

In the previous lessons, you learned how to set up our Wikipedia reader and the Yahoo Finance worker; we will now systemize the process and create separate process entities. You will learn to create queues, take elements, and place them in a queue.

7. Creating a Postgres Worker

In this lesson, we will create our instruction worker using a Postgres database.

8. Integrating the Postgres Worker

After creating our Postgres database insertion worker, we will integrate this worker into our main function and make changes to ensure that everything is working properly.

9. Yaml File Introduction

After creating a working program, you will learn how to clean up the appearance and make it nicer to have an overview and be able to expand its features in the future.

10. Creating a Yaml Reader

Now that we have the Yaml pipeline defined, we will implement something to read this file or any other file that has a queue worker structure to create our pipeline for us.

11. Improving Our Wiki Worker

After successfully creating and defining our Yaml reader, we will implement this into our main class.

12. Improving All Workers and Adding Monitoring

In this lecture, you will learn to clean up the Yaml pipeline executor, load the pipeline, initialize it, and join it to your main class.

13. Final Program Cleanup

Apart from a final cleanup to make our project more functional, you will learn to create local environment variables for actual testing.

14. Locking

This lecture will cover the locking process and things we need to vary when threading.


2. Multiprocessing

This section focuses on the multiprocessing functions in Python. You will learn to create multiprocessing queues and pools and learn all about arguments and checking elements in ranges.

1. Multiprocessing Introduction

Here, we will understand multiprocessing and monitor how our CPU functions during multiprocessing.

2. Multiprocessing Queues

Now that we have understood multiprocessing, you will learn how to split our segments over multiple processes in the form of queues to speed up processing and take a load off the process execution.

3. Multiprocessing Pool

After learning how to distribute the work by multiprocessing over different CPUs, you will learn to replicate the process over a multiprocessing program surrounding multiprocessing classes.

4. Multiprocessing Pool Map Multiple Arguments

Let's learn how to pass multiple arguments, passing lists instead of elements in a list or class while executing a code.

5. Multiprocessing Multiple Varying Arguments

In the previous video, we have seen how to provide additional arguments using a partial library in the functools built-in tool; you will now learn to add different elements such as a power list instead.

6. Multiprocessing Checking Elements in List in Certain Ranges

In this video, we will finally revisit the initially more CPU-intensive functions we were using, which will be checking how many values in our comparison list are in a specific range.


3. Asynchronous

This section focuses on the asynchronous programming aspect of Python. You will learn to write asynchronous programs, perform asynchronous tasks, use asynchronous libraries, and combine async and multiprocessing.

1. Introduction to Writing Asynchronous Programs

In this video, we will understand what asynchronous programming is and the fundamental differences between synchronous and asynchronous programming. We will also write our first asynchronous program.

2. Asynchronous Tasks

Here, you will learn to assign asynchronous functions to tasks to execute on the asynchronous syntax.

3. Async Gather Method

Let's understand how to combine two APIs using the gather method with the await function. Here, the function waits for all tasks to complete before executing the next task assigned.

4. Using Async Timeouts

This video will explain what a timeout does in asynchronous programming and how to place timeouts in our syntax.

5. Creating Asynchronous For Loops

This lesson elaborates on what a for loop does and does not do in an asynchronous program code.

6. Using Asynchronous Libraries

Here, you will learn how some libraries support asynchronous libraries, and others do not. You will also learn to look for those libraries and compare them.

7. The Async Wait Statement

In this video, we will look at how we can wait for specific tasks to complete before we execute the code we want to run. Unlike the gather function that waits for all tasks to complete before running a code, this statement waits for specific tasks to complete.

8. Combining Async and Multiprocessing

Course Content

  1. Concurrent and Parallel Programming in Python

About The Provider

Packt
Packt
Birmingham
Founded in 2004 in Birmingham, UK, Packt’s mission is to help the world put software to work in new ways, through the delivery of effective learning and i...
Read more about Packt

Tags

Reviews