
Concurrent Execution
********************

The modules described in this chapter provide support for concurrent
execution of code. The appropriate choice of tool will depend on the
task to be executed (CPU bound vs IO bound) and preferred style of
development (event driven cooperative multitasking vs preemptive
multitasking). Here's an overview:

* "threading" --- Thread-based parallelism

  * Thread-Local Data

  * Thread Objects

  * Lock Objects

  * RLock Objects

  * Condition Objects

  * Semaphore Objects

    * "Semaphore" Example

  * Event Objects

  * Timer Objects

  * Barrier Objects

  * Using locks, conditions, and semaphores in the "with" statement

* "multiprocessing" --- Process-based parallelism

  * Introduction

    * The "Process" class

    * Exchanging objects between processes

    * Synchronization between processes

    * Sharing state between processes

    * Using a pool of workers

  * Reference

    * "Process" and exceptions

    * Pipes and Queues

    * Miscellaneous

    * Connection Objects

    * Synchronization primitives

    * Shared "ctypes" Objects

      * The "multiprocessing.sharedctypes" module

    * Managers

      * Namespace objects

      * Customized managers

      * Using a remote manager

    * Proxy Objects

      * Cleanup

    * Process Pools

    * Listeners and Clients

      * Address Formats

    * Authentication keys

    * Logging

    * The "multiprocessing.dummy" module

  * Programming guidelines

    * All platforms

    * Windows

  * Examples

* The "concurrent" package

* "concurrent.futures" --- Launching parallel tasks

  * Executor Objects

  * ThreadPoolExecutor

    * ThreadPoolExecutor Example

  * ProcessPoolExecutor

    * ProcessPoolExecutor Example

  * Future Objects

  * Module Functions

  * Exception classes

* "subprocess" --- Subprocess management

  * Using the "subprocess" Module

    * Frequently Used Arguments

    * Popen Constructor

    * Exceptions

    * Security

  * Popen Objects

  * Windows Popen Helpers

    * Constants

  * Replacing Older Functions with the "subprocess" Module

    * Replacing /bin/sh shell backquote

    * Replacing shell pipeline

    * Replacing "os.system()"

    * Replacing the "os.spawn" family

    * Replacing "os.popen()", "os.popen2()", "os.popen3()"

    * Replacing functions from the "popen2" module

  * Legacy Shell Invocation Functions

  * Notes

    * Converting an argument sequence to a string on Windows

* "sched" --- Event scheduler

  * Scheduler Objects

* "queue" --- A synchronized queue class

  * Queue Objects

* "select" --- Waiting for I/O completion

  * "/dev/poll" Polling Objects

  * Edge and Level Trigger Polling (epoll) Objects

  * Polling Objects

  * Kqueue Objects

  * Kevent Objects

The following are support modules for some of the above services:

* "dummy_threading" --- Drop-in replacement for the "threading"
  module

* "_thread" --- Low-level threading API

* "_dummy_thread" --- Drop-in replacement for the "_thread" module
