A deadlock is a standstill in which concurrent participants wait indefinitely for resources held by one another, so the application cannot progress. A self-wait on a non-reentrant lock is one example; conflicting lock-acquisition orders create another. section 7.3.2
Two locks, circular waiting
Suppose method a acquires lock A, pauses, and then requests lock B, while method b acquires B and requests A. Each thread now holds one lock and waits for the other; the program hangs forever. Listing 7.11 demonstrates this with Python threads, locks, and an intentional delay. section 7.3.2
Subprocess pipes and full buffers
A subprocess can deadlock when its piped output fills the stream-reader buffer. The child blocks while writing, and the parent blocks waiting for completion without consuming output. Consume the stream concurrently or use process.communicate(), as shown with a program producing one million lines. section 13.1.1














