1 Getting to know asyncio

 

This chapter covers

  • What asyncio is and the benefits it provides
  • Concurrency, parallelism, threads, and processes
  • The global interpreter lock and the challenges it poses to concurrency
  • How non-blocking sockets can achieve concurrency with only one thread
  • The basics of how event-loop-based concurrency works

Many applications, especially in today’s world of web applications, rely heavily on I/O (input/output) operations. These types of operations include downloading the contents of a web page from the internet, communicating over a network with a group of microservices, or running several queries together against a database such as MySQL or Postgres. A web request or communication with a microservice may take hundreds of milliseconds, or even seconds if the network is slow. A database query could be time intensive, especially if that database is under high load or the query is complex. A web server may need to handle hundreds or thousands of requests at the same time.

1.1 What is asyncio?

1.2 What is I/O-bound and what is CPU-bound?

1.3 Understanding concurrency, parallelism, and multitasking

1.3.1 Concurrency

1.3.2 Parallelism

1.3.3 The difference between concurrency and parallelism

1.3.4 What is multitasking?

1.3.5 The benefits of cooperative multitasking

1.4 Understanding processes, threads, multithreading, and multiprocessing

1.4.1 Process

1.4.2 Thread

1.5 Understanding the global interpreter lock

1.5.1 Is the GIL ever released?

1.5.2 asyncio and the GIL

1.6 How single-threaded concurrency works

1.6.1 What is a socket?

1.7 How an event loop works

Summary

sitemap