並行執行 (Concurrent Execution)¶
本章節描述的模組在程式的並行執行上提供支援。選擇要使用哪一個工具則取決於是執行什麼樣的任務(CPU 密集或 IO 密集)與偏好的開發風格(事件驅動協作式多工處理或搶占式多工處理)。以下為此章節總覽:
threading--- Thread-based parallelismactive_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
withstatement
multiprocessing--- Process-based parallelism- 簡介
- Reference
Process與例外- Pipes and Queues
- Miscellaneous
- Connection Objects
- Synchronization primitives
- Shared
ctypesObjects - Managers
- Proxy Objects
- Process Pools
- Listeners and Clients
- Authentication keys
- Logging
- The
multiprocessing.dummymodule
- Programming guidelines
- 範例
multiprocessing.shared_memory--- 對於共享記憶體的跨行程直接存取concurrent套件concurrent.futures-- 啟動平行任務subprocess--- Subprocess management- Using the
subprocessModule - Security Considerations
- Popen Objects
- Windows Popen Helpers
STARTUPINFO- Windows Constants
STD_INPUT_HANDLESTD_OUTPUT_HANDLESTD_ERROR_HANDLESW_HIDESTARTF_USESTDHANDLESSTARTF_USESHOWWINDOWCREATE_NEW_CONSOLECREATE_NEW_PROCESS_GROUPABOVE_NORMAL_PRIORITY_CLASSBELOW_NORMAL_PRIORITY_CLASSHIGH_PRIORITY_CLASSIDLE_PRIORITY_CLASSNORMAL_PRIORITY_CLASSREALTIME_PRIORITY_CLASSCREATE_NO_WINDOWDETACHED_PROCESSCREATE_DEFAULT_ERROR_MODECREATE_BREAKAWAY_FROM_JOB
- Older high-level API
- Replacing Older Functions with the
subprocessModule - Legacy Shell Invocation Functions
- 註解
- Using the
sched--- Event schedulerqueue--- 同步佇列 (queue) class(類別)contextvars--- Context Variables
以下是支援部份上述服務的模組: