concurrency.md
1> **Источник:** https://python-all.ru/3.7/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.7/library/threading.html)1213 - [Потоковые локальные данные](https://python-all.ru/3.7/library/threading.html#thread-local-data)14 - [Объекты потоков](https://python-all.ru/3.7/library/threading.html#thread-objects)15 - [Объекты блокировок](https://python-all.ru/3.7/library/threading.html#lock-objects)16 - [Объекты RLock](https://python-all.ru/3.7/library/threading.html#rlock-objects)17 - [Объекты условий](https://python-all.ru/3.7/library/threading.html#condition-objects)18 - [Объекты семафоров](https://python-all.ru/3.7/library/threading.html#semaphore-objects)1920 - [`Semaphore` Пример](https://python-all.ru/3.7/library/threading.html#semaphore-example)21 - [Объекты событий](https://python-all.ru/3.7/library/threading.html#event-objects)22 - [Объекты таймеров](https://python-all.ru/3.7/library/threading.html#timer-objects)23 - [Объекты барьеров](https://python-all.ru/3.7/library/threading.html#barrier-objects)24 - [Использование блокировок, условий и семафоров в операторе `with`](https://python-all.ru/3.7/library/threading.html#using-locks-conditions-and-semaphores-in-the-with-statement)25- [`multiprocessing` – параллелизм на основе процессов](https://python-all.ru/3.7/library/multiprocessing.html)2627 - [Введение](https://python-all.ru/3.7/library/multiprocessing.html#introduction)2829 - [Класс `Process`](https://python-all.ru/3.7/library/multiprocessing.html#the-process-class)30 - [Контексты и методы запуска](https://python-all.ru/3.7/library/multiprocessing.html#contexts-and-start-methods)31 - [Обмен объектами между процессами](https://python-all.ru/3.7/library/multiprocessing.html#exchanging-objects-between-processes)32 - [Синхронизация между процессами](https://python-all.ru/3.7/library/multiprocessing.html#synchronization-between-processes)33 - [Совместное использование состояния между процессами](https://python-all.ru/3.7/library/multiprocessing.html#sharing-state-between-processes)34 - [Использование пула рабочих процессов](https://python-all.ru/3.7/library/multiprocessing.html#using-a-pool-of-workers)35 - [Справочник](https://python-all.ru/3.7/library/multiprocessing.html#reference)3637 - [`Process` и исключения](https://python-all.ru/3.7/library/multiprocessing.html#process-and-exceptions)38 - [Каналы и очереди](https://python-all.ru/3.7/library/multiprocessing.html#pipes-and-queues)39 - [Разное](https://python-all.ru/3.7/library/multiprocessing.html#miscellaneous)40 - [Объекты соединений](https://python-all.ru/3.7/library/multiprocessing.html#connection-objects)41 - [Примитивы синхронизации](https://python-all.ru/3.7/library/multiprocessing.html#synchronization-primitives)42 - [Разделяемые `ctypes` объекты](https://python-all.ru/3.7/library/multiprocessing.html#shared-ctypes-objects)4344 - [Модуль `multiprocessing.sharedctypes`](https://python-all.ru/3.7/library/multiprocessing.html#module-multiprocessing.sharedctypes)45 - [Менеджеры](https://python-all.ru/3.7/library/multiprocessing.html#managers)4647 - [Настраиваемые менеджеры](https://python-all.ru/3.7/library/multiprocessing.html#customized-managers)48 - [Использование удалённого менеджера](https://python-all.ru/3.7/library/multiprocessing.html#using-a-remote-manager)49 - [Объекты-прокси](https://python-all.ru/3.7/library/multiprocessing.html#proxy-objects)5051 - [Очистка](https://python-all.ru/3.7/library/multiprocessing.html#cleanup)52 - [Пулы процессов](https://python-all.ru/3.7/library/multiprocessing.html#module-multiprocessing.pool)53 - [Слушатели и клиенты](https://python-all.ru/3.7/library/multiprocessing.html#module-multiprocessing.connection)5455 - [Форматы адресов](https://python-all.ru/3.7/library/multiprocessing.html#address-formats)56 - [Ключи аутентификации](https://python-all.ru/3.7/library/multiprocessing.html#authentication-keys)57 - [Логирование](https://python-all.ru/3.7/library/multiprocessing.html#logging)58 - [Модуль `multiprocessing.dummy`](https://python-all.ru/3.7/library/multiprocessing.html#module-multiprocessing.dummy)59 - [Рекомендации по программированию](https://python-all.ru/3.7/library/multiprocessing.html#programming-guidelines)6061 - [Все методы запуска](https://python-all.ru/3.7/library/multiprocessing.html#all-start-methods)62 - [Методы запуска *spawn* и *forkserver*](https://python-all.ru/3.7/library/multiprocessing.html#the-spawn-and-forkserver-start-methods)63 - [Примеры](https://python-all.ru/3.7/library/multiprocessing.html#examples)64- [Пакет `concurrent`](https://python-all.ru/3.7/library/concurrent.html)65- [`concurrent.futures` – Запуск параллельных задач](https://python-all.ru/3.7/library/concurrent.futures.html)6667 - [Объекты исполнителя](https://python-all.ru/3.7/library/concurrent.futures.html#executor-objects)68 - [ThreadPoolExecutor](https://python-all.ru/3.7/library/concurrent.futures.html#threadpoolexecutor)6970 - [Пример ThreadPoolExecutor](https://python-all.ru/3.7/library/concurrent.futures.html#threadpoolexecutor-example)71 - [ProcessPoolExecutor](https://python-all.ru/3.7/library/concurrent.futures.html#processpoolexecutor)7273 - [Пример ProcessPoolExecutor](https://python-all.ru/3.7/library/concurrent.futures.html#processpoolexecutor-example)74 - [Объекты Future](https://python-all.ru/3.7/library/concurrent.futures.html#future-objects)75 - [Функции модуля](https://python-all.ru/3.7/library/concurrent.futures.html#module-functions)76 - [Классы исключений](https://python-all.ru/3.7/library/concurrent.futures.html#exception-classes)77- [`subprocess` – Управление подпроцессами](https://python-all.ru/3.7/library/subprocess.html)7879 - [Использование модуля `subprocess`](https://python-all.ru/3.7/library/subprocess.html#using-the-subprocess-module)8081 - [Часто используемые аргументы](https://python-all.ru/3.7/library/subprocess.html#frequently-used-arguments)82 - [Конструктор Popen](https://python-all.ru/3.7/library/subprocess.html#popen-constructor)83 - [Исключения](https://python-all.ru/3.7/library/subprocess.html#exceptions)84 - [Вопросы безопасности](https://python-all.ru/3.7/library/subprocess.html#security-considerations)85 - [Объекты Popen](https://python-all.ru/3.7/library/subprocess.html#popen-objects)86 - [Вспомогательные функции Popen для Windows](https://python-all.ru/3.7/library/subprocess.html#windows-popen-helpers)8788 - [Константы Windows](https://python-all.ru/3.7/library/subprocess.html#windows-constants)89 - [Старый высокоуровневый API](https://python-all.ru/3.7/library/subprocess.html#older-high-level-api)90 - [Замена старых функций модулем `subprocess`](https://python-all.ru/3.7/library/subprocess.html#replacing-older-functions-with-the-subprocess-module)9192 - [Замена обратных кавычек оболочки /bin/sh](https://python-all.ru/3.7/library/subprocess.html#replacing-bin-sh-shell-backquote)93 - [Замена конвейера оболочки](https://python-all.ru/3.7/library/subprocess.html#replacing-shell-pipeline)94 - [Замена `os.system()`](https://python-all.ru/3.7/library/subprocess.html#replacing-os-system)95 - [Замена семейства `os.spawn`](https://python-all.ru/3.7/library/subprocess.html#replacing-the-os-spawn-family)96 - [Замена `os.popen()`, `os.popen2()`, `os.popen3()`](https://python-all.ru/3.7/library/subprocess.html#replacing-os-popen-os-popen2-os-popen3)97 - [Замена функций из модуля `popen2`](https://python-all.ru/3.7/library/subprocess.html#replacing-functions-from-the-popen2-module)98 - [Устаревшие функции вызова оболочки](https://python-all.ru/3.7/library/subprocess.html#legacy-shell-invocation-functions)99 - [Примечания](https://python-all.ru/3.7/library/subprocess.html#notes)100101 - [Преобразование последовательности аргументов в строку на Windows](https://python-all.ru/3.7/library/subprocess.html#converting-an-argument-sequence-to-a-string-on-windows)102- [`sched` – планировщик событий](https://python-all.ru/3.7/library/sched.html)103104 - [Объекты планировщика](https://python-all.ru/3.7/library/sched.html#scheduler-objects)105- [`queue` – класс синхронизированной очереди](https://python-all.ru/3.7/library/queue.html)106107 - [Объекты очередей](https://python-all.ru/3.7/library/queue.html#queue-objects)108 - [Объекты SimpleQueue](https://python-all.ru/3.7/library/queue.html#simplequeue-objects)109110Ниже приведены вспомогательные модули для некоторых из перечисленных выше служб:111112- [`_thread` – низкоуровневый API потоков](https://python-all.ru/3.7/library/_thread.html)113- [`_dummy_thread` – прямая замена модуля `_thread`](https://python-all.ru/3.7/library/_dummy_thread.html)114- [`dummy_threading` – прямая замена модуля `threading`](https://python-all.ru/3.7/library/dummy_threading.html)115