concurrency.md
1> **Источник:** https://python-all.ru/3.15/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.15/library/threading.html)1213 - [Введение](https://python-all.ru/3.15/library/threading.html#introduction)14 - [GIL и соображения производительности](https://python-all.ru/3.15/library/threading.html#gil-and-performance-considerations)15 - [Справочник](https://python-all.ru/3.15/library/threading.html#reference)1617 - [Данные, локальные для потока](https://python-all.ru/3.15/library/threading.html#thread-local-data)18 - [Объекты потоков](https://python-all.ru/3.15/library/threading.html#thread-objects)19 - [Объекты блокировок](https://python-all.ru/3.15/library/threading.html#lock-objects)20 - [Объекты RLock](https://python-all.ru/3.15/library/threading.html#rlock-objects)21 - [Объекты условия](https://python-all.ru/3.15/library/threading.html#condition-objects)22 - [Объекты семафоров](https://python-all.ru/3.15/library/threading.html#semaphore-objects)23 - [Пример `Semaphore`](https://python-all.ru/3.15/library/threading.html#semaphore-example)24 - [Объекты событий](https://python-all.ru/3.15/library/threading.html#event-objects)25 - [Объекты таймеров](https://python-all.ru/3.15/library/threading.html#timer-objects)26 - [Объекты барьеров](https://python-all.ru/3.15/library/threading.html#barrier-objects)27 - [Использование блокировок, условий и семафоров в операторе `with`](https://python-all.ru/3.15/library/threading.html#using-locks-conditions-and-semaphores-in-the-with-statement)28 - [Синхронизация итераторов](https://python-all.ru/3.15/library/threading.html#iterator-synchronization)29- [`multiprocessing` – параллелизм на основе процессов](https://python-all.ru/3.15/library/multiprocessing.html)3031 - [Введение](https://python-all.ru/3.15/library/multiprocessing.html#introduction)3233 - [Класс `Process`](https://python-all.ru/3.15/library/multiprocessing.html#the-process-class)34 - [Контексты и методы запуска](https://python-all.ru/3.15/library/multiprocessing.html#contexts-and-start-methods)35 - [Обмен объектами между процессами](https://python-all.ru/3.15/library/multiprocessing.html#exchanging-objects-between-processes)36 - [Синхронизация между процессами](https://python-all.ru/3.15/library/multiprocessing.html#synchronization-between-processes)37 - [Совместное использование состояния между процессами](https://python-all.ru/3.15/library/multiprocessing.html#sharing-state-between-processes)38 - [Использование пула рабочих процессов](https://python-all.ru/3.15/library/multiprocessing.html#using-a-pool-of-workers)39 - [Справочник](https://python-all.ru/3.15/library/multiprocessing.html#reference)4041 - [Глобальный метод запуска](https://python-all.ru/3.15/library/multiprocessing.html#global-start-method)42 - [`Process` и исключения](https://python-all.ru/3.15/library/multiprocessing.html#process-and-exceptions)43 - [Каналы и очереди](https://python-all.ru/3.15/library/multiprocessing.html#pipes-and-queues)44 - [Разное](https://python-all.ru/3.15/library/multiprocessing.html#miscellaneous)45 - [Объекты соединений](https://python-all.ru/3.15/library/multiprocessing.html#connection-objects)46 - [Примитивы синхронизации](https://python-all.ru/3.15/library/multiprocessing.html#synchronization-primitives)47 - [Разделяемые `ctypes` объекты](https://python-all.ru/3.15/library/multiprocessing.html#shared-ctypes-objects)4849 - [Модуль `multiprocessing.sharedctypes`](https://python-all.ru/3.15/library/multiprocessing.html#module-multiprocessing.sharedctypes)50 - [Менеджеры](https://python-all.ru/3.15/library/multiprocessing.html#managers)5152 - [Настраиваемые менеджеры](https://python-all.ru/3.15/library/multiprocessing.html#customized-managers)53 - [Использование удалённого менеджера](https://python-all.ru/3.15/library/multiprocessing.html#using-a-remote-manager)54 - [Объекты-прокси](https://python-all.ru/3.15/library/multiprocessing.html#proxy-objects)5556 - [Очистка](https://python-all.ru/3.15/library/multiprocessing.html#cleanup)57 - [Пулы процессов](https://python-all.ru/3.15/library/multiprocessing.html#module-multiprocessing.pool)58 - [Слушатели и клиенты](https://python-all.ru/3.15/library/multiprocessing.html#module-multiprocessing.connection)5960 - [Форматы адресов](https://python-all.ru/3.15/library/multiprocessing.html#address-formats)61 - [Ключи аутентификации](https://python-all.ru/3.15/library/multiprocessing.html#authentication-keys)62 - [Логирование](https://python-all.ru/3.15/library/multiprocessing.html#logging)63 - [Модуль `multiprocessing.dummy`](https://python-all.ru/3.15/library/multiprocessing.html#module-multiprocessing.dummy)64 - [Рекомендации по программированию](https://python-all.ru/3.15/library/multiprocessing.html#programming-guidelines)6566 - [Все методы запуска](https://python-all.ru/3.15/library/multiprocessing.html#all-start-methods)67 - [Методы запуска *spawn* и *forkserver*](https://python-all.ru/3.15/library/multiprocessing.html#the-spawn-and-forkserver-start-methods)68 - [Примеры](https://python-all.ru/3.15/library/multiprocessing.html#examples)69- [`multiprocessing.shared_memory` – Разделяемая память для прямого доступа между процессами](https://python-all.ru/3.15/library/multiprocessing.shared_memory.html)70- [Пакет `concurrent`](https://python-all.ru/3.15/library/concurrent.html)71- [`concurrent.futures` – Запуск параллельных задач](https://python-all.ru/3.15/library/concurrent.futures.html)7273 - [Объекты исполнителя](https://python-all.ru/3.15/library/concurrent.futures.html#executor-objects)74 - [ThreadPoolExecutor](https://python-all.ru/3.15/library/concurrent.futures.html#threadpoolexecutor)7576 - [Пример ThreadPoolExecutor](https://python-all.ru/3.15/library/concurrent.futures.html#threadpoolexecutor-example)77 - [InterpreterPoolExecutor](https://python-all.ru/3.15/library/concurrent.futures.html#interpreterpoolexecutor)78 - [ProcessPoolExecutor](https://python-all.ru/3.15/library/concurrent.futures.html#processpoolexecutor)7980 - [Пример ProcessPoolExecutor](https://python-all.ru/3.15/library/concurrent.futures.html#processpoolexecutor-example)81 - [Объекты Future](https://python-all.ru/3.15/library/concurrent.futures.html#future-objects)82 - [Функции модуля](https://python-all.ru/3.15/library/concurrent.futures.html#module-functions)83 - [Классы исключений](https://python-all.ru/3.15/library/concurrent.futures.html#exception-classes)84- [`concurrent.interpreters` – Несколько интерпретаторов в одном процессе](https://python-all.ru/3.15/library/concurrent.interpreters.html)8586 - [Ключевые детали](https://python-all.ru/3.15/library/concurrent.interpreters.html#key-details)87 - [Введение](https://python-all.ru/3.15/library/concurrent.interpreters.html#introduction)8889 - [Несколько интерпретаторов и изоляция](https://python-all.ru/3.15/library/concurrent.interpreters.html#multiple-interpreters-and-isolation)90 - [Запуск в интерпретаторе](https://python-all.ru/3.15/library/concurrent.interpreters.html#running-in-an-interpreter)91 - [Конкурентность и параллелизм](https://python-all.ru/3.15/library/concurrent.interpreters.html#concurrency-and-parallelism)92 - [Взаимодействие между интерпретаторами](https://python-all.ru/3.15/library/concurrent.interpreters.html#communication-between-interpreters)93 - [«Совместное использование» объектов](https://python-all.ru/3.15/library/concurrent.interpreters.html#sharing-objects)94 - [Справочник](https://python-all.ru/3.15/library/concurrent.interpreters.html#reference)9596 - [Объекты интерпретатора](https://python-all.ru/3.15/library/concurrent.interpreters.html#interpreter-objects)97 - [Исключения](https://python-all.ru/3.15/library/concurrent.interpreters.html#exceptions)98 - [Взаимодействие между интерпретаторами](https://python-all.ru/3.15/library/concurrent.interpreters.html#communicating-between-interpreters)99 - [Основы использования](https://python-all.ru/3.15/library/concurrent.interpreters.html#basic-usage)100- [`subprocess` – Управление подпроцессами](https://python-all.ru/3.15/library/subprocess.html)101102 - [Использование модуля `subprocess`](https://python-all.ru/3.15/library/subprocess.html#using-the-subprocess-module)103104 - [Часто используемые аргументы](https://python-all.ru/3.15/library/subprocess.html#frequently-used-arguments)105 - [Конструктор Popen](https://python-all.ru/3.15/library/subprocess.html#popen-constructor)106 - [Исключения](https://python-all.ru/3.15/library/subprocess.html#exceptions)107 - [Вопросы безопасности](https://python-all.ru/3.15/library/subprocess.html#security-considerations)108 - [Объекты Popen](https://python-all.ru/3.15/library/subprocess.html#popen-objects)109 - [Вспомогательные функции Popen для Windows](https://python-all.ru/3.15/library/subprocess.html#windows-popen-helpers)110111 - [Константы Windows](https://python-all.ru/3.15/library/subprocess.html#windows-constants)112 - [Старый высокоуровневый API](https://python-all.ru/3.15/library/subprocess.html#older-high-level-api)113 - [Замена старых функций модулем `subprocess`](https://python-all.ru/3.15/library/subprocess.html#replacing-older-functions-with-the-subprocess-module)114115 - [Замена подстановки команд оболочки **/bin/sh**](https://python-all.ru/3.15/library/subprocess.html#replacing-bin-sh-shell-command-substitution)116 - [Замена конвейера оболочки](https://python-all.ru/3.15/library/subprocess.html#replacing-shell-pipeline)117 - [Замена `os.system()`](https://python-all.ru/3.15/library/subprocess.html#replacing-os-system)118 - [Замена семейства `os.spawn`](https://python-all.ru/3.15/library/subprocess.html#replacing-the-os-spawn-family)119 - [Замена `os.popen()`](https://python-all.ru/3.15/library/subprocess.html#replacing-os-popen)120 - [Устаревшие функции вызова оболочки](https://python-all.ru/3.15/library/subprocess.html#legacy-shell-invocation-functions)121 - [Примечания](https://python-all.ru/3.15/library/subprocess.html#notes)122123 - [Поведение при тайм-ауте](https://python-all.ru/3.15/library/subprocess.html#timeout-behavior)124 - [Преобразование последовательности аргументов в строку на Windows](https://python-all.ru/3.15/library/subprocess.html#converting-an-argument-sequence-to-a-string-on-windows)125 - [Отключение использования `posix_spawn()`](https://python-all.ru/3.15/library/subprocess.html#disable-use-of-posix-spawn)126- [`sched` – планировщик событий](https://python-all.ru/3.15/library/sched.html)127128 - [Объекты планировщика](https://python-all.ru/3.15/library/sched.html#scheduler-objects)129- [`queue` – класс синхронизированной очереди](https://python-all.ru/3.15/library/queue.html)130131 - [Объекты очередей](https://python-all.ru/3.15/library/queue.html#queue-objects)132133 - [Ожидание завершения задачи](https://python-all.ru/3.15/library/queue.html#waiting-for-task-completion)134 - [Завершение очередей](https://python-all.ru/3.15/library/queue.html#terminating-queues)135 - [Объекты SimpleQueue](https://python-all.ru/3.15/library/queue.html#simplequeue-objects)136- [`contextvars` – контекстные переменные](https://python-all.ru/3.15/library/contextvars.html)137138 - [Контекстные переменные](https://python-all.ru/3.15/library/contextvars.html#context-variables)139 - [Ручное управление контекстом](https://python-all.ru/3.15/library/contextvars.html#manual-context-management)140 - [Поддержка asyncio](https://python-all.ru/3.15/library/contextvars.html#asyncio-support)141142Ниже приведены вспомогательные модули для некоторых из перечисленных выше служб:143144- [`_thread` – низкоуровневый API потоков](https://python-all.ru/3.15/library/_thread.html)145