concurrency.md
1> **Источник:** https://python-all.ru/3.11/library/concurrency.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# Параллельное выполнение89Модули, описанные в этой главе, обеспечивают поддержку параллельного выполнения кода. Выбор подходящего инструмента зависит от выполняемой задачи (с привязкой к ЦП или к вводу-выводу) и предпочитаемого стиля разработки (событийно-ориентированная кооперативная многозадачность или вытесняющая многозадачность). Ниже приведён обзор:1011- [`threading` – параллелизм на основе потоков](https://python-all.ru/3.11/library/threading.html)1213 - [Потоковые локальные данные](https://python-all.ru/3.11/library/threading.html#thread-local-data)14 - [Объекты потоков](https://python-all.ru/3.11/library/threading.html#thread-objects)15 - [Объекты блокировок](https://python-all.ru/3.11/library/threading.html#lock-objects)16 - [Объекты RLock](https://python-all.ru/3.11/library/threading.html#rlock-objects)17 - [Объекты условий](https://python-all.ru/3.11/library/threading.html#condition-objects)18 - [Объекты семафоров](https://python-all.ru/3.11/library/threading.html#semaphore-objects)1920 - [`Semaphore` Пример](https://python-all.ru/3.11/library/threading.html#semaphore-example)21 - [Объекты событий](https://python-all.ru/3.11/library/threading.html#event-objects)22 - [Объекты таймеров](https://python-all.ru/3.11/library/threading.html#timer-objects)23 - [Объекты барьеров](https://python-all.ru/3.11/library/threading.html#barrier-objects)24 - [Использование блокировок, условий и семафоров в операторе `with`](https://python-all.ru/3.11/library/threading.html#using-locks-conditions-and-semaphores-in-the-with-statement)25- [`multiprocessing` – параллелизм на основе процессов](https://python-all.ru/3.11/library/multiprocessing.html)2627 - [Введение](https://python-all.ru/3.11/library/multiprocessing.html#introduction)2829 - [Класс `Process`](https://python-all.ru/3.11/library/multiprocessing.html#the-process-class)30 - [Контексты и методы запуска](https://python-all.ru/3.11/library/multiprocessing.html#contexts-and-start-methods)31 - [Обмен объектами между процессами](https://python-all.ru/3.11/library/multiprocessing.html#exchanging-objects-between-processes)32 - [Синхронизация между процессами](https://python-all.ru/3.11/library/multiprocessing.html#synchronization-between-processes)33 - [Совместное использование состояния между процессами](https://python-all.ru/3.11/library/multiprocessing.html#sharing-state-between-processes)34 - [Использование пула рабочих процессов](https://python-all.ru/3.11/library/multiprocessing.html#using-a-pool-of-workers)35 - [Справочник](https://python-all.ru/3.11/library/multiprocessing.html#reference)3637 - [`Process` и исключения](https://python-all.ru/3.11/library/multiprocessing.html#process-and-exceptions)38 - [Каналы и очереди](https://python-all.ru/3.11/library/multiprocessing.html#pipes-and-queues)39 - [Разное](https://python-all.ru/3.11/library/multiprocessing.html#miscellaneous)40 - [Объекты соединений](https://python-all.ru/3.11/library/multiprocessing.html#connection-objects)41 - [Примитивы синхронизации](https://python-all.ru/3.11/library/multiprocessing.html#synchronization-primitives)42 - [Разделяемые `ctypes` объекты](https://python-all.ru/3.11/library/multiprocessing.html#shared-ctypes-objects)4344 - [Модуль `multiprocessing.sharedctypes`](https://python-all.ru/3.11/library/multiprocessing.html#module-multiprocessing.sharedctypes)45 - [Менеджеры](https://python-all.ru/3.11/library/multiprocessing.html#managers)4647 - [Настраиваемые менеджеры](https://python-all.ru/3.11/library/multiprocessing.html#customized-managers)48 - [Использование удалённого менеджера](https://python-all.ru/3.11/library/multiprocessing.html#using-a-remote-manager)49 - [Объекты-прокси](https://python-all.ru/3.11/library/multiprocessing.html#proxy-objects)5051 - [Очистка](https://python-all.ru/3.11/library/multiprocessing.html#cleanup)52 - [Пулы процессов](https://python-all.ru/3.11/library/multiprocessing.html#module-multiprocessing.pool)53 - [Слушатели и клиенты](https://python-all.ru/3.11/library/multiprocessing.html#module-multiprocessing.connection)5455 - [Форматы адресов](https://python-all.ru/3.11/library/multiprocessing.html#address-formats)56 - [Ключи аутентификации](https://python-all.ru/3.11/library/multiprocessing.html#authentication-keys)57 - [Логирование](https://python-all.ru/3.11/library/multiprocessing.html#logging)58 - [Модуль `multiprocessing.dummy`](https://python-all.ru/3.11/library/multiprocessing.html#module-multiprocessing.dummy)59 - [Рекомендации по программированию](https://python-all.ru/3.11/library/multiprocessing.html#programming-guidelines)6061 - [Все методы запуска](https://python-all.ru/3.11/library/multiprocessing.html#all-start-methods)62 - [Методы запуска *spawn* и *forkserver*](https://python-all.ru/3.11/library/multiprocessing.html#the-spawn-and-forkserver-start-methods)63 - [Примеры](https://python-all.ru/3.11/library/multiprocessing.html#examples)64- [`multiprocessing.shared_memory` – Разделяемая память для прямого доступа между процессами](https://python-all.ru/3.11/library/multiprocessing.shared_memory.html)65- [Пакет `concurrent`](https://python-all.ru/3.11/library/concurrent.html)66- [`concurrent.futures` – Запуск параллельных задач](https://python-all.ru/3.11/library/concurrent.futures.html)6768 - [Объекты исполнителя](https://python-all.ru/3.11/library/concurrent.futures.html#executor-objects)69 - [ThreadPoolExecutor](https://python-all.ru/3.11/library/concurrent.futures.html#threadpoolexecutor)7071 - [Пример ThreadPoolExecutor](https://python-all.ru/3.11/library/concurrent.futures.html#threadpoolexecutor-example)72 - [ProcessPoolExecutor](https://python-all.ru/3.11/library/concurrent.futures.html#processpoolexecutor)7374 - [Пример ProcessPoolExecutor](https://python-all.ru/3.11/library/concurrent.futures.html#processpoolexecutor-example)75 - [Объекты Future](https://python-all.ru/3.11/library/concurrent.futures.html#future-objects)76 - [Функции модуля](https://python-all.ru/3.11/library/concurrent.futures.html#module-functions)77 - [Классы исключений](https://python-all.ru/3.11/library/concurrent.futures.html#exception-classes)78- [`subprocess` – Управление подпроцессами](https://python-all.ru/3.11/library/subprocess.html)7980 - [Использование модуля `subprocess`](https://python-all.ru/3.11/library/subprocess.html#using-the-subprocess-module)8182 - [Часто используемые аргументы](https://python-all.ru/3.11/library/subprocess.html#frequently-used-arguments)83 - [Конструктор Popen](https://python-all.ru/3.11/library/subprocess.html#popen-constructor)84 - [Исключения](https://python-all.ru/3.11/library/subprocess.html#exceptions)85 - [Вопросы безопасности](https://python-all.ru/3.11/library/subprocess.html#security-considerations)86 - [Объекты Popen](https://python-all.ru/3.11/library/subprocess.html#popen-objects)87 - [Вспомогательные функции Popen для Windows](https://python-all.ru/3.11/library/subprocess.html#windows-popen-helpers)8889 - [Константы Windows](https://python-all.ru/3.11/library/subprocess.html#windows-constants)90 - [Старый высокоуровневый API](https://python-all.ru/3.11/library/subprocess.html#older-high-level-api)91 - [Замена старых функций модулем `subprocess`](https://python-all.ru/3.11/library/subprocess.html#replacing-older-functions-with-the-subprocess-module)9293 - [Замена подстановки команд оболочки **/bin/sh**](https://python-all.ru/3.11/library/subprocess.html#replacing-bin-sh-shell-command-substitution)94 - [Замена конвейера оболочки](https://python-all.ru/3.11/library/subprocess.html#replacing-shell-pipeline)95 - [Замена `os.system()`](https://python-all.ru/3.11/library/subprocess.html#replacing-os-system)96 - [Замена семейства `os.spawn`](https://python-all.ru/3.11/library/subprocess.html#replacing-the-os-spawn-family)97 - [Замена `os.popen()`, `os.popen2()`, `os.popen3()`](https://python-all.ru/3.11/library/subprocess.html#replacing-os-popen-os-popen2-os-popen3)98 - [Замена функций из модуля `popen2`](https://python-all.ru/3.11/library/subprocess.html#replacing-functions-from-the-popen2-module)99 - [Устаревшие функции вызова оболочки](https://python-all.ru/3.11/library/subprocess.html#legacy-shell-invocation-functions)100 - [Примечания](https://python-all.ru/3.11/library/subprocess.html#notes)101102 - [Преобразование последовательности аргументов в строку на Windows](https://python-all.ru/3.11/library/subprocess.html#converting-an-argument-sequence-to-a-string-on-windows)103 - [Отключение использования `vfork()` или `posix_spawn()`](https://python-all.ru/3.11/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn)104- [`sched` – планировщик событий](https://python-all.ru/3.11/library/sched.html)105106 - [Объекты планировщика](https://python-all.ru/3.11/library/sched.html#scheduler-objects)107- [`queue` – класс синхронизированной очереди](https://python-all.ru/3.11/library/queue.html)108109 - [Объекты очередей](https://python-all.ru/3.11/library/queue.html#queue-objects)110 - [Объекты SimpleQueue](https://python-all.ru/3.11/library/queue.html#simplequeue-objects)111- [`contextvars` – контекстные переменные](https://python-all.ru/3.11/library/contextvars.html)112113 - [Контекстные переменные](https://python-all.ru/3.11/library/contextvars.html#context-variables)114 - [Ручное управление контекстом](https://python-all.ru/3.11/library/contextvars.html#manual-context-management)115 - [Поддержка asyncio](https://python-all.ru/3.11/library/contextvars.html#asyncio-support)116117Ниже приведены вспомогательные модули для некоторых из перечисленных выше служб:118119- [`_thread` – низкоуровневый API потоков](https://python-all.ru/3.11/library/_thread.html)120