並行執行 (Concurrent Execution)¶
本章節描述的模組在程式的並行執行上提供支援。選擇要使用哪一個工具則取決於是執行什麼樣的任務(CPU 密集或 IO 密集)與偏好的開發風格(事件驅動協作式多工處理或搶占式多工處理)。以下為此章節總覽:
threading
--- 基於執行緒的平行性active_count()
current_thread()
excepthook()
__excepthook__
get_ident()
get_native_id()
enumerate()
main_thread()
settrace()
settrace_all_threads()
gettrace()
setprofile()
setprofile_all_threads()
getprofile()
stack_size()
TIMEOUT_MAX
- Thread-Local Data
- Thread Objects
- Lock Objects
- RLock 物件
- Condition Objects
- Semaphore Objects
- Event Objects
- Timer Objects
- Barrier Objects
- Using locks, conditions, and semaphores in the
with
statement
multiprocessing
--- 以行程為基礎的平行性multiprocessing.shared_memory
--- 對於共享記憶體的跨行程直接存取concurrent
套件concurrent.futures
--- 啟動平行任務subprocess
--- 子行程管理- Using the
subprocess
Module - 安全性注意事項
- Popen Objects
- Windows Popen Helpers
STARTUPINFO
- Windows Constants
STD_INPUT_HANDLE
STD_OUTPUT_HANDLE
STD_ERROR_HANDLE
SW_HIDE
STARTF_USESTDHANDLES
STARTF_USESHOWWINDOW
CREATE_NEW_CONSOLE
CREATE_NEW_PROCESS_GROUP
ABOVE_NORMAL_PRIORITY_CLASS
BELOW_NORMAL_PRIORITY_CLASS
HIGH_PRIORITY_CLASS
IDLE_PRIORITY_CLASS
NORMAL_PRIORITY_CLASS
REALTIME_PRIORITY_CLASS
CREATE_NO_WINDOW
DETACHED_PROCESS
CREATE_DEFAULT_ERROR_MODE
CREATE_BREAKAWAY_FROM_JOB
- Older high-level API
- Replacing Older Functions with the
subprocess
Module - Legacy Shell Invocation Functions
- 註解
- Using the
sched
--- 事件排程器queue
--- 同步佇列 (synchronized queue) 類別contextvars
--- 情境變數
以下是支援部份上述服務的模組: