並行執行 (Concurrent Execution)
*******************************

本章節描述的模組在程式的並行執行上提供支援。選擇要使用哪一個工具則取決
於是執行什麼樣的任務（CPU 密集或 IO 密集）與偏好的開發風格（事件驅動協
作式多工處理或搶占式多工處理）。以下為此章節總覽：

* "threading" --- 基於執行緒的平行性

  * Introduction

  * GIL and performance considerations

  * Reference

    * Thread-local data

    * Thread 物件

    * Lock 物件

    * RLock 物件

    * Condition objects

    * Semaphore 物件

    * "Semaphore" 範例

    * Event objects

    * Timer 物件

    * Barrier 物件

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

* "multiprocessing" --- 以行程為基礎的平行性

  * 簡介

    * "Process" 類別

    * Contexts and start methods

    * Exchanging objects between processes

    * Synchronization between processes

    * Sharing state between processes

    * Using a pool of workers

  * Reference

    * Global start method

    * "Process" 與例外

    * Pipes and Queues

    * Miscellaneous

    * Connection Objects

    * Synchronization primitives

    * 共享的 "ctypes" 物件

      * "multiprocessing.sharedctypes" 模組

    * Managers

      * Customized managers

      * Using a remote manager

    * Proxy Objects

      * Cleanup

    * Process Pools

    * Listeners and Clients

      * Address Formats

    * Authentication keys

    * Logging

    * "multiprocessing.dummy" 模組

  * Programming guidelines

    * All start methods

    * The *spawn* and *forkserver* start methods

  * 範例

* "multiprocessing.shared_memory" --- 對於共享記憶體的跨行程直接存取

* "concurrent" 套件

* "concurrent.futures" --- 啟動平行任務

  * Executor 物件

  * ThreadPoolExecutor

    * ThreadPoolExecutor 範例

  * ProcessPoolExecutor

    * ProcessPoolExecutor 範例

  * Future 物件

  * 模組函式

  * 例外類別

* "subprocess" --- 子行程管理

  * Using the "subprocess" Module

    * Frequently Used Arguments

    * Popen Constructor

    * 例外

  * 安全性注意事項

  * Popen Objects

  * Windows Popen Helpers

    * Windows Constants

  * Older high-level API

  * Replacing Older Functions with the "subprocess" Module

    * Replacing **/bin/sh** shell command substitution

    * 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

  * 註解

    * Timeout Behavior

    * Converting an argument sequence to a string on Windows

    * 停用 "vfork()" 或 "posix_spawn()"

* "sched" --- 事件排程器

  * 排程器物件

* "queue" --- 同步佇列 (synchronized queue) 類別

  * 佇列物件

    * Waiting for task completion

    * Terminating queues

  * SimpleQueue 物件

* "contextvars" --- 情境變數

  * 情境變數

  * 手動情境管理

  * 對 asyncio 的支援

以下是支援部份上述服務的模組：

* "_thread" --- 低階執行緒 API
