Skip to Content
Introducing Python, 2nd Edition
book

Introducing Python, 2nd Edition

by Bill Lubanovic
November 2019
Beginner
630 pages
12h 20m
English
O'Reilly Media, Inc.
Book available
Content preview from Introducing Python, 2nd Edition

Chapter 15. Data in Time: Processes and Concurrency

One thing a computer can do that most humans can’t is be sealed up in a cardboard box and sit in a warehouse.

Jack Handey

This chapter and the next two are a bit more challenging than earlier ones. In this one we cover data in time (sequential and concurrent access on a single computer), and following that we look at data in a box (storage and retrieval with special files and databases) in Chapter 16 and then data in space (networking) in Chapter 17.

Programs and Processes

When you run an individual program, your operating system creates a single process. It uses system resources (CPU, memory, disk space) and data structures in the operating system’s kernel (file and network connections, usage statistics, and so on). A process is isolated from other processes—it can’t see what other processes are doing or interfere with them.

The operating system keeps track of all the running processes, giving each a little time to run and then switching to another, with the twin goals of spreading the work around fairly and being responsive to the user. You can see the state of your processes with graphical interfaces such as the Mac’s Activity Monitor (macOS), Task Manager on Windows-based computers, or the top command in Linux.

You can also access process data from your own programs. The standard library’s os module provides a common way of accessing some system information. For instance, the following functions get the process ID and ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Fluent Python, 2nd Edition

Fluent Python, 2nd Edition

Luciano Ramalho

Publisher Resources

ISBN: 9781492051374Errata PageSupplemental Content