{"id":3539,"date":"2026-09-19T05:32:54","date_gmt":"2026-09-19T05:32:54","guid":{"rendered":"https:\/\/otus.ru\/journal\/?p=3539"},"modified":"2026-09-25T15:43:34","modified_gmt":"2026-09-25T15:43:34","slug":"threads-v-python","status":"publish","type":"post","link":"https:\/\/otus.ru\/journal\/threads-v-python\/","title":{"rendered":"\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 Python: threading, GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d multiprocessing"},"content":{"rendered":"<p><strong>\u041f\u043e\u0442\u043e\u043a (thread)<\/strong> &#8212; \u044d\u0442\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u0412 Python \u043f\u043e\u0442\u043e\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044c <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">threading<\/code>.<\/p>\n<div class=\"oj-toc\" style=\"background:#f6f6f6;border-radius:8px;padding:14px 20px;margin:20px 0\">\n<p><strong>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/strong><\/p>\n<ol>\n<li><a href=\"#s1\">\u041f\u043e\u0442\u043e\u043a, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438 GIL: \u0442\u0440\u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0443\u0442\u0430\u044e\u0442<\/a><\/li>\n<li><a href=\"#s2\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u0442\u043e\u043a: threading.Thread<\/a><\/li>\n<li><a href=\"#s3\">\u0414\u0435\u043c\u043e\u043d-\u043f\u043e\u0442\u043e\u043a\u0438 \u0438 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/a><\/li>\n<li><a href=\"#s4\">\u0413\u043e\u043d\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445: \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0443\u0436\u0435\u043d Lock<\/a><\/li>\n<li><a href=\"#s5\">GIL \u043d\u0430 CPU-bound \u0437\u0430\u0434\u0430\u0447\u0435: \u043f\u043e\u0442\u043e\u043a\u0438 \u043f\u0440\u043e\u0442\u0438\u0432 multiprocessing<\/a><\/li>\n<li><a href=\"#s6\">Free-threaded Python: GIL \u0441\u0442\u0430\u043b \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c<\/a><\/li>\n<li><a href=\"#s7\">\u0412\u044b\u0432\u043e\u0434\u044b<\/a><\/li>\n<li><a href=\"#s8\">\u0413\u0434\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \/ \u0441\u0432\u044f\u0437\u044c \u0441 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439<\/a><\/li>\n<li><a href=\"#s9\">FAQ<\/a><\/li>\n<\/ol>\n<\/div>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a, \u0447\u0435\u043c \u043f\u043e\u0442\u043e\u043a \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438 GIL, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0433\u043e\u043d\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u0430\u043a \u0435\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">Lock<\/code>, \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0434\u043b\u044f \u0442\u044f\u0436\u0435\u043b\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043f\u043e\u0442\u043e\u043a\u0438 \u043d\u0435 \u0443\u0441\u043a\u043e\u0440\u044f\u044e\u0442 \u043a\u043e\u0434 &#8212; \u0438 \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0438\u0445.<\/p>\n<h2 id=\"s1\">\u041f\u043e\u0442\u043e\u043a, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438 GIL: \u0442\u0440\u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0443\u0442\u0430\u044e\u0442<\/h2>\n<p>\u0422\u0440\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u0440\u044f\u0434\u043e\u043c, \u0438 \u0438\u0445 \u043b\u0435\u0433\u043a\u043e \u0441\u043c\u0435\u0448\u0430\u0442\u044c:<\/p>\n<ul>\n<li><strong>\u041f\u0440\u043e\u0446\u0435\u0441\u0441<\/strong> &#8212; \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432 \u0441\u0432\u043e\u0435\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043d\u0435 \u0434\u0435\u043b\u044f\u0442 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.<\/li>\n<li><strong>\u041f\u043e\u0442\u043e\u043a<\/strong> &#8212; \u0435\u0434\u0438\u043d\u0438\u0446\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u0412\u0441\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0434\u0435\u043b\u044f\u0442 \u043e\u0431\u0449\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/li>\n<li><strong>GIL (Global Interpreter Lock)<\/strong> &#8212; \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 \u0432 CPython (\u044d\u0442\u0430\u043b\u043e\u043d\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Python), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0431\u0430\u0439\u0442\u043a\u043e\u0434 Python \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/li>\n<\/ul>\n<p>\u0418\u0437-\u0437\u0430 GIL \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 Python \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0431\u0430\u0439\u0442\u043a\u043e\u0434 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0434\u0440\u0430\u0445. \u041d\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 (\u0441\u0435\u0442\u044c, \u0434\u0438\u0441\u043a, <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">time.sleep<\/code>) \u043f\u043e\u0442\u043e\u043a \u043e\u0442\u0434\u0430\u0435\u0442 GIL, \u0438 \u0432 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0438 \u0432 Python \u0434\u0430\u044e\u0442 \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u043d\u0430 I\/O-bound \u0437\u0430\u0434\u0430\u0447\u0430\u0445 (\u0441\u0435\u0442\u044c, \u0444\u0430\u0439\u043b\u044b, \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435) \u0438 \u043d\u0435 \u0434\u0430\u044e\u0442 \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0430 \u043d\u0430 CPU-bound \u0437\u0430\u0434\u0430\u0447\u0430\u0445 (\u0440\u0430\u0441\u0447\u0435\u0442\u044b, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0438\u0441\u0435\u043b) &#8212; \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430 \u043d\u0438\u0436\u0435.<\/p>\n<h2 id=\"s2\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u0442\u043e\u043a: threading.Thread<\/h2>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 &#8212; \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430, \u043a\u0430\u0436\u0434\u044b\u0439 \u0436\u0434\u0435\u0442 \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441:<\/p>\n<pre style=\"background:#282c34;color:#abb2bf;border-radius:8px;padding:16px 20px;margin:20px 0;overflow-x:auto;font-size:14px;line-height:1.55;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\"><code style=\"background:none\"><span style=\"color: #C678DD\">import<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">threading<\/span>\n<span style=\"color: #C678DD\">import<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">time<\/span>\n\n<span style=\"color: #C678DD\">def<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF; font-weight: bold\">worker<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">name<\/span><span style=\"color: #ABB2BF\">,<\/span> <span style=\"color: #E06C75\">delay<\/span><span style=\"color: #ABB2BF\">):<\/span>\n    <span style=\"color: #E5C07B\">print<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">f\"{<\/span><span style=\"color: #E06C75\">name<\/span><span style=\"color: #98C379\">}: \u0441\u0442\u0430\u0440\u0442\"<\/span><span style=\"color: #ABB2BF\">)<\/span>\n    <span style=\"color: #E06C75\">time<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">sleep<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">delay<\/span><span style=\"color: #ABB2BF\">)<\/span>\n    <span style=\"color: #E5C07B\">print<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">f\"{<\/span><span style=\"color: #E06C75\">name<\/span><span style=\"color: #98C379\">}: \u0444\u0438\u043d\u0438\u0448\"<\/span><span style=\"color: #ABB2BF\">)<\/span>\n\n<span style=\"color: #E06C75\">t1<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #E06C75\">threading<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">Thread<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">target<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #E06C75\">worker<\/span><span style=\"color: #ABB2BF\">,<\/span> <span style=\"color: #E06C75\">args<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">\"\u041f\u043e\u0442\u043e\u043a-1\"<\/span><span style=\"color: #ABB2BF\">,<\/span> <span style=\"color: #D19A66\">1<\/span><span style=\"color: #ABB2BF\">))<\/span>\n<span style=\"color: #E06C75\">t2<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #E06C75\">threading<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">Thread<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">target<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #E06C75\">worker<\/span><span style=\"color: #ABB2BF\">,<\/span> <span style=\"color: #E06C75\">args<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">\"\u041f\u043e\u0442\u043e\u043a-2\"<\/span><span style=\"color: #ABB2BF\">,<\/span> <span style=\"color: #D19A66\">1<\/span><span style=\"color: #ABB2BF\">))<\/span>\n\n<span style=\"color: #E06C75\">start<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #E06C75\">time<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">time<\/span><span style=\"color: #ABB2BF\">()<\/span>\n<span style=\"color: #E06C75\">t1<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">start<\/span><span style=\"color: #ABB2BF\">()<\/span>\n<span style=\"color: #E06C75\">t2<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">start<\/span><span style=\"color: #ABB2BF\">()<\/span>\n<span style=\"color: #E06C75\">t1<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">join<\/span><span style=\"color: #ABB2BF\">()<\/span>\n<span style=\"color: #E06C75\">t2<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">join<\/span><span style=\"color: #ABB2BF\">()<\/span>\n<span style=\"color: #E5C07B\">print<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">f\"\u0418\u0442\u043e\u0433\u043e: {<\/span><span style=\"color: #E06C75\">time<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">time<\/span><span style=\"color: #ABB2BF\">() <\/span><span style=\"color: #56B6C2\">-<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">start<\/span><span style=\"color: #98C379\">:.1f} \u0441\"<\/span><span style=\"color: #ABB2BF\">)<\/span><\/code><\/pre>\n<p>\u041e\u0431\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u043f\u043e\u0447\u0442\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u043e\u0431\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 &#171;\u0441\u0442\u0430\u0440\u0442&#187; \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0440\u044f\u0434\u043e\u043c, \u0437\u0430\u0442\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 &#8212; \u043e\u0431\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 &#171;\u0444\u0438\u043d\u0438\u0448&#187;. \u0418\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f &#8212; \u043e\u043a\u043e\u043b\u043e 1.0 \u0441, \u0430 \u043d\u0435 2.0 \u0441: <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">time.sleep<\/code> \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 GIL, \u0438 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0438\u0434\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">join()<\/code> \u0434\u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430, \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e\u0442\u043e\u043a\u0438.<\/p>\n<h2 id=\"s3\">\u0414\u0435\u043c\u043e\u043d-\u043f\u043e\u0442\u043e\u043a\u0438 \u0438 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u043e\u0442\u043e\u043a &#8212; \u043d\u0435 \u0434\u0435\u043c\u043e\u043d: \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 Python \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f, \u043f\u043e\u043a\u0430 \u0436\u0438\u0432 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0442\u043e\u043a, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043e\u0448\u043b\u0430 \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u0415\u0441\u043b\u0438 \u043f\u043e\u0442\u043e\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0444\u043e\u043d\u0435 \u0438 \u043d\u0435 \u043c\u0435\u0448\u0430\u0442\u044c \u0432\u044b\u0445\u043e\u0434\u0443 \u0438\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0435\u0433\u043e \u043f\u043e\u043c\u0435\u0447\u0430\u044e\u0442 \u0434\u0435\u043c\u043e\u043d-\u043f\u043e\u0442\u043e\u043a\u043e\u043c \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430:<\/p>\n<pre style=\"background:#282c34;color:#abb2bf;border-radius:8px;padding:16px 20px;margin:20px 0;overflow-x:auto;font-size:14px;line-height:1.55;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\"><code style=\"background:none\"><span style=\"color: #C678DD\">import<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">threading<\/span>\n<span style=\"color: #C678DD\">import<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">time<\/span>\n\n<span style=\"color: #C678DD\">def<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF; font-weight: bold\">background_task<\/span><span style=\"color: #ABB2BF\">():<\/span>\n    <span style=\"color: #C678DD\">while<\/span> <span style=\"color: #E5C07B\">True<\/span><span style=\"color: #ABB2BF\">:<\/span>\n        <span style=\"color: #E06C75\">time<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">sleep<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">5<\/span><span style=\"color: #ABB2BF\">)<\/span>\n\n<span style=\"color: #E06C75\">t<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #E06C75\">threading<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">Thread<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">target<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #E06C75\">background_task<\/span><span style=\"color: #ABB2BF\">,<\/span> <span style=\"color: #E06C75\">daemon<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #E5C07B\">True<\/span><span style=\"color: #ABB2BF\">)<\/span>\n<span style=\"color: #E06C75\">t<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">start<\/span><span style=\"color: #ABB2BF\">()<\/span>\n<span style=\"color: #E5C07B\">print<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">\"\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f\"<\/span><span style=\"color: #ABB2BF\">)<\/span><\/code><\/pre>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430, \u043d\u0435 \u0434\u043e\u0436\u0438\u0434\u0430\u044f\u0441\u044c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">background_task<\/code> &#8212; \u0434\u0435\u043c\u043e\u043d-\u043f\u043e\u0442\u043e\u043a\u0438 \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c &#8212; \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0442\u043e\u043a\u0430:<\/p>\n<pre style=\"background:#282c34;color:#abb2bf;border-radius:8px;padding:16px 20px;margin:20px 0;overflow-x:auto;font-size:14px;line-height:1.55;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\"><code style=\"background:none\"><span style=\"color: #C678DD\">import<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">threading<\/span>\n\n<span style=\"color: #C678DD\">def<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF; font-weight: bold\">broken<\/span><span style=\"color: #ABB2BF\">():<\/span>\n    <span style=\"color: #C678DD\">raise<\/span> <span style=\"color: #E06C75\">ValueError<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">\"\u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a\"<\/span><span style=\"color: #ABB2BF\">)<\/span>\n\n<span style=\"color: #E06C75\">t<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #E06C75\">threading<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">Thread<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">target<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #E06C75\">broken<\/span><span style=\"color: #ABB2BF\">)<\/span>\n<span style=\"color: #E06C75\">t<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">start<\/span><span style=\"color: #ABB2BF\">()<\/span>\n<span style=\"color: #E06C75\">t<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">join<\/span><span style=\"color: #ABB2BF\">()<\/span>\n<span style=\"color: #E5C07B\">print<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">\"\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u0434\u043e\u0448\u0435\u043b \u0434\u043e \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438\"<\/span><span style=\"color: #ABB2BF\">)<\/span><\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">ValueError<\/code> \u0438\u0437 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">Thread-1<\/code>, \u043d\u043e \u0441\u043b\u0435\u0434\u043e\u043c \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442\u0441\u044f &#171;\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u0434\u043e\u0448\u0435\u043b \u0434\u043e \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438&#187;: <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">join()<\/code> \u043d\u0435 \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u0430 \u043d\u0430\u0432\u0435\u0440\u0445, \u043e\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0435\u043a\u0442\u0440\u0435\u0439\u0441 \u0438 \u043d\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435, \u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0439\u043c\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043d\u0430\u0440\u0443\u0436\u0443 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0435\u0440\u0435\u0437 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">queue.Queue<\/code>) \u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">concurrent.futures.ThreadPoolExecutor<\/code>, \u0433\u0434\u0435 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">future.result()<\/code> \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u0442 \u0442\u043e \u0436\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043a\u043e\u0434\u0435.<\/p>\n<h2 id=\"s4\">\u0413\u043e\u043d\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445: \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0443\u0436\u0435\u043d Lock<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043c\u0435\u043d\u044f\u044e\u0442 \u043e\u0434\u043d\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0431\u0435\u0437 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c &#8212; \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0433\u043e\u043d\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (race condition):<\/p>\n<pre style=\"background:#282c34;color:#abb2bf;border-radius:8px;padding:16px 20px;margin:20px 0;overflow-x:auto;font-size:14px;line-height:1.55;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\"><code style=\"background:none\"><span style=\"color: #C678DD\">import<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">threading<\/span>\n\n<span style=\"color: #E06C75\">counter<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #D19A66\">0<\/span>\n\n<span style=\"color: #C678DD\">def<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF; font-weight: bold\">increment<\/span><span style=\"color: #ABB2BF\">():<\/span>\n    <span style=\"color: #C678DD\">global<\/span> <span style=\"color: #E06C75\">counter<\/span>\n    <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">_<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E5C07B\">range<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">100_000<\/span><span style=\"color: #ABB2BF\">):<\/span>\n        <span style=\"color: #E06C75\">counter<\/span> <span style=\"color: #56B6C2\">+=<\/span> <span style=\"color: #D19A66\">1<\/span>\n\n<span style=\"color: #E06C75\">threads<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #ABB2BF\">[<\/span><span style=\"color: #E06C75\">threading<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">Thread<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">target<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #E06C75\">increment<\/span><span style=\"color: #ABB2BF\">)<\/span> <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">_<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E5C07B\">range<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">4<\/span><span style=\"color: #ABB2BF\">)]<\/span>\n<span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">t<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E06C75\">threads<\/span><span style=\"color: #ABB2BF\">:<\/span>\n    <span style=\"color: #E06C75\">t<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">start<\/span><span style=\"color: #ABB2BF\">()<\/span>\n<span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">t<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E06C75\">threads<\/span><span style=\"color: #ABB2BF\">:<\/span>\n    <span style=\"color: #E06C75\">t<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">join<\/span><span style=\"color: #ABB2BF\">()<\/span>\n\n<span style=\"color: #E5C07B\">print<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">counter<\/span><span style=\"color: #ABB2BF\">)<\/span><\/code><\/pre>\n<p>\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u043e 400 000 (4 \u043f\u043e\u0442\u043e\u043a\u0430 \u043f\u043e 100 000 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u0432). \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0435 \u0438 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0443 &#8212; \u0442\u043e\u0447\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 Python, \u041e\u0421 \u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0443. \u041f\u0440\u0438\u0447\u0438\u043d\u0430: <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">counter += 1<\/code> &#8212; \u044d\u0442\u043e \u043d\u0435 \u043e\u0434\u043d\u0430 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u0438 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0448\u0430\u0433\u0430\u043c\u0438 GIL \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439, \u043f\u043e\u0442\u0435\u0440\u044f\u0432 \u0447\u0430\u0441\u0442\u044c \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0442\u0430\u043b \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c, \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043e\u0431\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0432 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">Lock<\/code>:<\/p>\n<pre style=\"background:#282c34;color:#abb2bf;border-radius:8px;padding:16px 20px;margin:20px 0;overflow-x:auto;font-size:14px;line-height:1.55;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\"><code style=\"background:none\"><span style=\"color: #C678DD\">import<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">threading<\/span>\n\n<span style=\"color: #E06C75\">counter<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #D19A66\">0<\/span>\n<span style=\"color: #E06C75\">lock<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #E06C75\">threading<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">Lock<\/span><span style=\"color: #ABB2BF\">()<\/span>\n\n<span style=\"color: #C678DD\">def<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF; font-weight: bold\">increment<\/span><span style=\"color: #ABB2BF\">():<\/span>\n    <span style=\"color: #C678DD\">global<\/span> <span style=\"color: #E06C75\">counter<\/span>\n    <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">_<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E5C07B\">range<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">100_000<\/span><span style=\"color: #ABB2BF\">):<\/span>\n        <span style=\"color: #C678DD\">with<\/span> <span style=\"color: #E06C75\">lock<\/span><span style=\"color: #ABB2BF\">:<\/span>\n            <span style=\"color: #E06C75\">counter<\/span> <span style=\"color: #56B6C2\">+=<\/span> <span style=\"color: #D19A66\">1<\/span>\n\n<span style=\"color: #E06C75\">threads<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #ABB2BF\">[<\/span><span style=\"color: #E06C75\">threading<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">Thread<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">target<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #E06C75\">increment<\/span><span style=\"color: #ABB2BF\">)<\/span> <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">_<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E5C07B\">range<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">4<\/span><span style=\"color: #ABB2BF\">)]<\/span>\n<span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">t<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E06C75\">threads<\/span><span style=\"color: #ABB2BF\">:<\/span>\n    <span style=\"color: #E06C75\">t<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">start<\/span><span style=\"color: #ABB2BF\">()<\/span>\n<span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">t<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E06C75\">threads<\/span><span style=\"color: #ABB2BF\">:<\/span>\n    <span style=\"color: #E06C75\">t<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">join<\/span><span style=\"color: #ABB2BF\">()<\/span>\n\n<span style=\"color: #E5C07B\">print<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">counter<\/span><span style=\"color: #ABB2BF\">)<\/span><\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e 400000: <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">with lock<\/code> \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0432 \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0439 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u0437\u0430 \u0440\u0430\u0437, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0436\u0434\u0443\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438. \u042d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c: <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">Lock<\/code> \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0442 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043d\u043e \u043e\u0431\u0435\u0440\u043d\u0443\u0442 \u0432 \u043d\u0435\u0433\u043e, &#8212; \u0435\u0441\u043b\u0438 \u0437\u0430\u0431\u044b\u0442\u044c \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u043e \u043c\u0435\u0441\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0433\u043e\u043d\u043a\u0430 \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f.<\/p>\n<h2 id=\"s5\">GIL \u043d\u0430 CPU-bound \u0437\u0430\u0434\u0430\u0447\u0435: \u043f\u043e\u0442\u043e\u043a\u0438 \u043f\u0440\u043e\u0442\u0438\u0432 multiprocessing<\/h2>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0441\u0447\u0435\u0442\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0431\u0435\u0437 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 &#8212; \u0441\u0443\u043c\u043c\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0432 \u0446\u0438\u043a\u043b\u0435:<\/p>\n<pre style=\"background:#282c34;color:#abb2bf;border-radius:8px;padding:16px 20px;margin:20px 0;overflow-x:auto;font-size:14px;line-height:1.55;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\"><code style=\"background:none\"><span style=\"color: #C678DD\">import<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">time<\/span>\n<span style=\"color: #C678DD\">from<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">threading<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">import<\/span> <span style=\"color: #E06C75\">Thread<\/span>\n<span style=\"color: #C678DD\">from<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">multiprocessing<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">import<\/span> <span style=\"color: #E06C75\">Process<\/span>\n\n<span style=\"color: #C678DD\">def<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF; font-weight: bold\">cpu_task<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">n<\/span><span style=\"color: #ABB2BF\">):<\/span>\n    <span style=\"color: #E06C75\">total<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #D19A66\">0<\/span>\n    <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">i<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E5C07B\">range<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">n<\/span><span style=\"color: #ABB2BF\">):<\/span>\n        <span style=\"color: #E06C75\">total<\/span> <span style=\"color: #56B6C2\">+=<\/span> <span style=\"color: #E06C75\">i<\/span> <span style=\"color: #56B6C2\">*<\/span> <span style=\"color: #E06C75\">i<\/span>\n    <span style=\"color: #C678DD\">return<\/span> <span style=\"color: #E06C75\">total<\/span>\n\n<span style=\"color: #E06C75\">N<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #D19A66\">20_000_000<\/span>\n\n<span style=\"color: #C678DD\">def<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF; font-weight: bold\">run_threads<\/span><span style=\"color: #ABB2BF\">():<\/span>\n    <span style=\"color: #E06C75\">threads<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #ABB2BF\">[<\/span><span style=\"color: #E06C75\">Thread<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">target<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #E06C75\">cpu_task<\/span><span style=\"color: #ABB2BF\">,<\/span> <span style=\"color: #E06C75\">args<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">N<\/span> <span style=\"color: #56B6C2\">\/\/<\/span> <span style=\"color: #D19A66\">2<\/span><span style=\"color: #ABB2BF\">,))<\/span> <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">_<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E5C07B\">range<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">2<\/span><span style=\"color: #ABB2BF\">)]<\/span>\n    <span style=\"color: #E06C75\">start<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #E06C75\">time<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">time<\/span><span style=\"color: #ABB2BF\">()<\/span>\n    <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">t<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E06C75\">threads<\/span><span style=\"color: #ABB2BF\">:<\/span>\n        <span style=\"color: #E06C75\">t<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">start<\/span><span style=\"color: #ABB2BF\">()<\/span>\n    <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">t<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E06C75\">threads<\/span><span style=\"color: #ABB2BF\">:<\/span>\n        <span style=\"color: #E06C75\">t<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">join<\/span><span style=\"color: #ABB2BF\">()<\/span>\n    <span style=\"color: #C678DD\">return<\/span> <span style=\"color: #E06C75\">time<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">time<\/span><span style=\"color: #ABB2BF\">()<\/span> <span style=\"color: #56B6C2\">-<\/span> <span style=\"color: #E06C75\">start<\/span>\n\n<span style=\"color: #C678DD\">def<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF; font-weight: bold\">run_processes<\/span><span style=\"color: #ABB2BF\">():<\/span>\n    <span style=\"color: #E06C75\">processes<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #ABB2BF\">[<\/span><span style=\"color: #E06C75\">Process<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">target<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #E06C75\">cpu_task<\/span><span style=\"color: #ABB2BF\">,<\/span> <span style=\"color: #E06C75\">args<\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">N<\/span> <span style=\"color: #56B6C2\">\/\/<\/span> <span style=\"color: #D19A66\">2<\/span><span style=\"color: #ABB2BF\">,))<\/span> <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">_<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E5C07B\">range<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">2<\/span><span style=\"color: #ABB2BF\">)]<\/span>\n    <span style=\"color: #E06C75\">start<\/span> <span style=\"color: #56B6C2\">=<\/span> <span style=\"color: #E06C75\">time<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">time<\/span><span style=\"color: #ABB2BF\">()<\/span>\n    <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">p<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E06C75\">processes<\/span><span style=\"color: #ABB2BF\">:<\/span>\n        <span style=\"color: #E06C75\">p<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">start<\/span><span style=\"color: #ABB2BF\">()<\/span>\n    <span style=\"color: #C678DD\">for<\/span> <span style=\"color: #E06C75\">p<\/span> <span style=\"color: #56B6C2\">in<\/span> <span style=\"color: #E06C75\">processes<\/span><span style=\"color: #ABB2BF\">:<\/span>\n        <span style=\"color: #E06C75\">p<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">join<\/span><span style=\"color: #ABB2BF\">()<\/span>\n    <span style=\"color: #C678DD\">return<\/span> <span style=\"color: #E06C75\">time<\/span><span style=\"color: #56B6C2\">.<\/span><span style=\"color: #E06C75\">time<\/span><span style=\"color: #ABB2BF\">()<\/span> <span style=\"color: #56B6C2\">-<\/span> <span style=\"color: #E06C75\">start<\/span>\n\n<span style=\"color: #C678DD\">if<\/span> <span style=\"color: #E06C75\">__name__<\/span> <span style=\"color: #56B6C2\">==<\/span> <span style=\"color: #98C379\">\"__main__\"<\/span><span style=\"color: #ABB2BF\">:<\/span>\n    <span style=\"color: #E5C07B\">print<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">f\"\u041f\u043e\u0442\u043e\u043a\u0438: {<\/span><span style=\"color: #E06C75\">run_threads<\/span><span style=\"color: #ABB2BF\">()<\/span><span style=\"color: #98C379\">:.1f} \u0441\"<\/span><span style=\"color: #ABB2BF\">)<\/span>\n    <span style=\"color: #E5C07B\">print<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">f\"\u041f\u0440\u043e\u0446\u0435\u0441\u0441\u044b: {<\/span><span style=\"color: #E06C75\">run_processes<\/span><span style=\"color: #ABB2BF\">()<\/span><span style=\"color: #98C379\">:.1f} \u0441\"<\/span><span style=\"color: #ABB2BF\">)<\/span><\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">if __name__ == \"__main__\":<\/code> &#8212; \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u0437\u0430\u0449\u0438\u0442\u044b \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445 \u0443\u0439\u0434\u0435\u0442 \u0432 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u0438\u043c\u043f\u043e\u0440\u0442 \u043c\u043e\u0434\u0443\u043b\u044f.<\/p>\n<p>\u041d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u044f\u0434\u0440\u0430\u043c\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u043d\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430: GIL \u043d\u0435 \u0434\u0430\u0435\u0442 \u0434\u0432\u0443\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0431\u0430\u0439\u0442\u043a\u043e\u0434 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u043d\u0430 \u043c\u043d\u043e\u0433\u043e\u044f\u0434\u0435\u0440\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0438 \u0441\u0432\u043e\u0439 GIL, \u0438 \u043e\u043d\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0434\u0440\u0430\u0445. \u0422\u043e\u0447\u043d\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0447\u0438\u0441\u043b\u0430 \u044f\u0434\u0435\u0440 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u0430\u0448\u0438\u043d\u044b &#8212; \u0432 \u00ab\u0422\u043e\u0447\u043a\u0430\u0445 \u0434\u043b\u044f \u0444\u0430\u043a\u0442\u0447\u0435\u043a\u0430\u00bb \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0421\u0432\u043e\u0434\u043a\u0430, \u043a\u043e\u0433\u0434\u0430 \u0447\u0442\u043e \u0431\u0440\u0430\u0442\u044c:<\/p>\n<table>\n<thead>\n<tr>\n<th>\u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c<\/th>\n<th>\u0427\u0442\u043e \u0434\u0430\u0435\u0442<\/th>\n<th>\u041a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/th>\n<th>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>threading<\/td>\n<td>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435<\/td>\n<td>I\/O-bound: \u0441\u0435\u0442\u044c, \u0444\u0430\u0439\u043b\u044b, \u0411\u0414<\/td>\n<td>\u041d\u0435 \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 CPU-bound \u0438\u0437-\u0437\u0430 GIL<\/td>\n<\/tr>\n<tr>\n<td>multiprocessing<\/td>\n<td>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u044f\u0434\u0440\u0430\u0445<\/td>\n<td>CPU-bound: \u0440\u0430\u0441\u0447\u0435\u0442\u044b, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/td>\n<td>\u0414\u043e\u0440\u043e\u0436\u0435 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438, \u043e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0436\u043d\u0435\u0435<\/td>\n<\/tr>\n<tr>\n<td>asyncio<\/td>\n<td>\u041e\u0434\u043d\u0430 \u043d\u0438\u0442\u044c, \u043a\u043e\u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/td>\n<td>\u041c\u043d\u043e\u0433\u043e I\/O-\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0439 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e (\u0442\u044b\u0441\u044f\u0447\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439)<\/td>\n<td>\u041a\u043e\u0434 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c async-\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u043c\u0438<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"s6\">Free-threaded Python: GIL \u0441\u0442\u0430\u043b \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c<\/h2>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Python 3.13 \u0432 CPython \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0441\u0431\u043e\u0440\u043a\u0430 \u0431\u0435\u0437 GIL (free-threaded, PEP 703, \u0444\u043b\u0430\u0433 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">--disable-gil<\/code> \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435, \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a \u0432\u0438\u0434\u0430 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">python3.13t<\/code>). \u0412 \u0442\u0430\u043a\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0431\u0430\u0439\u0442\u043a\u043e\u0434 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0434\u0440\u0430\u0445.<\/p>\n<p>\u0412 Python 3.13 \u044d\u0442\u043e\u0442 \u0440\u0435\u0436\u0438\u043c \u0431\u044b\u043b \u043f\u043e\u043c\u0435\u0447\u0435\u043d \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c. \u0412 Python 3.14 free-threaded \u0441\u0431\u043e\u0440\u043a\u0430 \u043f\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c PEP 779 \u043f\u0435\u0440\u0435\u0448\u043b\u0430 \u0432 \u0441\u0442\u0430\u0442\u0443\u0441 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0439 &#8212; \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e GIL \u0443\u0431\u0440\u0430\u043b\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e: \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 CPython \u0441 GIL \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0431\u043e\u0440\u043a\u043e\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0430 free-threaded \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u0427\u0430\u0441\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0441 C-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c\u0438 \u043a free-threaded \u0441\u0431\u043e\u0440\u043a\u0435 \u0435\u0449\u0435 \u0434\u043e\u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0430 \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043d\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0438\u0434\u0442\u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u0441 GIL. \u0414\u043b\u044f \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 CPython \u0441 GIL, free-threaded \u0441\u0431\u043e\u0440\u043a\u0443 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0432 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/p>\n<h2 id=\"s7\">\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<ul>\n<li>\u041f\u043e\u0442\u043e\u043a &#8212; \u0435\u0434\u0438\u043d\u0438\u0446\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043f\u043e\u0442\u043e\u043a\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0434\u0435\u043b\u044f\u0442 \u043f\u0430\u043c\u044f\u0442\u044c.<\/li>\n<li>GIL \u0432 CPython \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0431\u0430\u0439\u0442\u043a\u043e\u0434 Python \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0438 \u0443\u0441\u043a\u043e\u0440\u044f\u044e\u0442 I\/O-bound \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u043d\u0435 \u0443\u0441\u043a\u043e\u0440\u044f\u044e\u0442 CPU-bound.<\/li>\n<li>\u041e\u0431\u0449\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">Lock<\/code> &#8212; \u0438\u043d\u0430\u0447\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0433\u043e\u043d\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043d\u0435\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c.<\/li>\n<li>\u0414\u043b\u044f \u0442\u044f\u0436\u0435\u043b\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044f\u0434\u0440\u0430\u0445 \u043d\u0443\u0436\u0435\u043d <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">multiprocessing<\/code>, \u0430 \u043d\u0435 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">threading<\/code>.<\/li>\n<li>Free-threaded Python (PEP 703) \u0441\u043d\u0438\u043c\u0430\u0435\u0442 GIL \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435: \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0432 3.13, \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u0430\u044f \u0441 3.14 (PEP 779), \u043d\u043e \u043d\u0435 \u0441\u0431\u043e\u0440\u043a\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/li>\n<\/ul>\n<h2 id=\"s8\">\u0413\u0434\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \/ \u0441\u0432\u044f\u0437\u044c \u0441 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439<\/h2>\n<div class=\"oj-cta\" style=\"background:#fbf4e4;border-left:4px solid #c9962b;border-radius:8px;padding:16px 20px;margin:24px 0\">\n<p style=\"margin:0 0 8px\"><strong>\u041e\u0441\u0432\u043e\u0439\u0442\u0435 \u0442\u0435\u043c\u0443 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435<\/strong><\/p>\n<p>\u041c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 GIL &#8212; \u0431\u0430\u0437\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0443\u0436\u043d\u0430 \u043d\u0430 \u043b\u044e\u0431\u043e\u043c Python-\u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441 \u0441\u0435\u0442\u0435\u0432\u044b\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438, \u0444\u043e\u043d\u043e\u0432\u044b\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432: \u0431\u0435\u0437 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043c\u0435\u0436\u0434\u0443 I\/O-bound \u0438 CPU-bound \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0440\u0430\u0441\u0447\u0435\u0442\u044b \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0438 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0430. \u0422\u0435\u043c\u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0430 \u043a\u0443\u0440\u0441\u0435 <a href=\"https:\/\/otus.ru\/lessons\/python-basic\/?int_article=threads-v-python&amp;int_place=article&amp;int_variant=v1\">Python Basic<\/a> &#8212; \u0442\u0430\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u043a\u0430\u043a \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u0435\u0436\u0434\u0443 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">threading<\/code>, <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">multiprocessing<\/code> \u0438 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">asyncio<\/code> \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445.<\/p>\n<\/div>\n<div class=\"oj-cta\" style=\"background:#fbf4e4;border-left:4px solid #c9962b;border-radius:8px;padding:16px 20px;margin:24px 0\">\n<p style=\"margin:0 0 8px\"><strong>\u041e\u0441\u0432\u043e\u0439\u0442\u0435 \u0442\u0435\u043c\u0443 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u043a\u0443\u0440\u0441\u0443 &#8212; \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 <a href=\"https:\/\/otus.ru\/events\/?int_article=threads-v-python&amp;int_place=article&amp;int_variant=v1\">\u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0443\u0440\u043e\u043a\u043e\u0432 Otus<\/a>: \u0442\u0430\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0442\u0435\u043c\u044b Python \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043d\u044f\u0442\u0438\u044f.<\/p>\n<\/div>\n<p>\u0421\u043c\u0435\u0436\u043d\u044b\u0435 \u0442\u0435\u043c\u044b: \u0421\u043b\u043e\u0432\u0430\u0440\u0438 \u0432 Python \u0438 \u0438\u0445 \u043f\u0435\u0440\u0435\u0431\u043e\u0440, Java Concurrency: \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e\u0442\u043e\u043a\u0438 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435.<\/p>\n<h2 id=\"s9\">FAQ<\/h2>\n<p><strong>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 asyncio?<\/strong><br \/>\n\u0422\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0430, \u043d\u043e \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u043a\u043e\u0434: async-\u043a\u043e\u0434 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d \u043d\u0430 \u043e\u0434\u043d\u0443 \u043d\u0438\u0442\u044c \u0441 \u043a\u043e\u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c, \u0430 \u043f\u0440\u0438\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">threading<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0446\u0438\u043a\u043b\u043e\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438. \u0414\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u043f\u043e\u0434\u0445\u043e\u0434 &#8212; \u043b\u0438\u0431\u043e <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">asyncio<\/code>, \u043b\u0438\u0431\u043e <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">threading<\/code> &#8212; \u043f\u043e\u0434 \u0442\u0438\u043f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<p><strong>\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 Python?<\/strong><br \/>\n\u0424\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043b\u0438\u043c\u0438\u0442\u0430 \u0432 \u044f\u0437\u044b\u043a\u0435 \u043d\u0435\u0442, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 &#8212; \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430 \u0441\u0442\u0435\u043a \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u0414\u043b\u044f \u0441\u043e\u0442\u0435\u043d \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 I\/O-\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (<code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">concurrent.futures.ThreadPoolExecutor<\/code>) \u0438\u043b\u0438 <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">asyncio<\/code>, \u0430 \u043d\u0435 \u0442\u044b\u0441\u044f\u0447\u0438 \u0440\u0443\u0447\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<p><strong>\u041d\u0443\u0436\u0435\u043d \u043b\u0438 Lock, \u0435\u0441\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0442\u0430\u044e\u0442 \u043e\u0431\u0449\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0435\u0435?<\/strong><br \/>\n\u0415\u0441\u043b\u0438 \u043d\u0438 \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u043f\u0438\u0448\u0435\u0442 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u0430\u043c\u043e \u043f\u043e \u0441\u0435\u0431\u0435 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0433\u043e\u043d\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. <code style=\"background:#eef0f3;color:#24292f;border-radius:4px;padding:1px 5px;font-size:0.92em;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace\">Lock<\/code> \u043d\u0443\u0436\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442, \u043f\u043e\u043a\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0435\u0435 \u0447\u0438\u0442\u0430\u044e\u0442 \u0438\u043b\u0438 \u0442\u043e\u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u043e\u0442\u043e\u043a (thread) &#8212; \u044d\u0442\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u0412 Python \u043f\u043e\u0442\u043e\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044c threading. \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u041f\u043e\u0442\u043e\u043a, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438 GIL: \u0442\u0440\u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0443\u0442\u0430\u044e\u0442 \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u0442\u043e\u043a: threading.Thread \u0414\u0435\u043c\u043e\u043d-\u043f\u043e\u0442\u043e\u043a\u0438 \u0438 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0413\u043e\u043d\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445: \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0443\u0436\u0435\u043d Lock GIL \u043d\u0430 CPU-bound \u0437\u0430\u0434\u0430\u0447\u0435: \u043f\u043e\u0442\u043e\u043a\u0438 [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":3540,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[27],"class_list":["post-3539","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-polza","tag-python"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c threading \u0432 Python: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, Lock, \u0433\u043e\u043d\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u044f CPU-bound \u0437\u0430\u0434\u0430\u0447 \u043d\u0443\u0436\u0435\u043d multiprocessing \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"A. Pavlenko\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/otus.ru\/journal\/threads-v-python\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#article\",\"name\":\"\\u041f\\u043e\\u0442\\u043e\\u043a\\u0438 \\u0432 Python: threading \\u0438 GIL \\u043d\\u0430 \\u043f\\u0440\\u0430\\u043a\\u0442\\u0438\\u043a\\u0435 | Otus\",\"headline\":\"\\u041f\\u043e\\u0442\\u043e\\u043a\\u0438 \\u0432 Python: threading, GIL \\u0438 \\u043a\\u043e\\u0433\\u0434\\u0430 \\u043d\\u0443\\u0436\\u0435\\u043d multiprocessing\",\"author\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/author\\\/a-pavlenko\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/otus.ru\\\/journal\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/oj-1080x720-14.png\",\"width\":1080,\"height\":720},\"datePublished\":\"2026-09-19T05:32:54+00:00\",\"dateModified\":\"2026-09-25T15:43:34+00:00\",\"inLanguage\":\"ru-RU\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#webpage\"},\"articleSection\":\"\\u041f\\u043e\\u043b\\u0435\\u0437\\u043d\\u043e\\u0435, Python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/otus.ru\\\/journal\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/category\\\/polza\\\/#listItem\",\"name\":\"\\u041f\\u043e\\u043b\\u0435\\u0437\\u043d\\u043e\\u0435\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/category\\\/polza\\\/#listItem\",\"position\":2,\"name\":\"\\u041f\\u043e\\u043b\\u0435\\u0437\\u043d\\u043e\\u0435\",\"item\":\"https:\\\/\\\/otus.ru\\\/journal\\\/category\\\/polza\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#listItem\",\"name\":\"\\u041f\\u043e\\u0442\\u043e\\u043a\\u0438 \\u0432 Python: threading, GIL \\u0438 \\u043a\\u043e\\u0433\\u0434\\u0430 \\u043d\\u0443\\u0436\\u0435\\u043d multiprocessing\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#listItem\",\"position\":3,\"name\":\"\\u041f\\u043e\\u0442\\u043e\\u043a\\u0438 \\u0432 Python: threading, GIL \\u0438 \\u043a\\u043e\\u0433\\u0434\\u0430 \\u043d\\u0443\\u0436\\u0435\\u043d multiprocessing\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/category\\\/polza\\\/#listItem\",\"name\":\"\\u041f\\u043e\\u043b\\u0435\\u0437\\u043d\\u043e\\u0435\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/#organization\",\"name\":\"\\u041e\\u0442\\u0443\\u0441 \\u043e\\u043d\\u043b\\u0430\\u0439\\u043d-\\u043e\\u0431\\u0440\\u0430\\u0437\\u043e\\u0432\\u0430\\u043d\\u0438\\u0435\",\"description\":\"\\u0411\\u043b\\u043e\\u0433 \\u043f\\u0440\\u043e IT\",\"url\":\"https:\\\/\\\/otus.ru\\\/journal\\\/\",\"telephone\":\"+74999389202\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/otus.ru\\\/journal\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/OTUS-journal-logo-180x180-1.png\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#organizationLogo\",\"width\":180,\"height\":180},\"image\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#organizationLogo\"},\"sameAs\":[\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCetgtvy93o3i3CvyGXKFU3g\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/author\\\/a-pavlenko\\\/#author\",\"url\":\"https:\\\/\\\/otus.ru\\\/journal\\\/author\\\/a-pavlenko\\\/\",\"name\":\"A. Pavlenko\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/13488c7d5b657aaaf1808afd398f71e0225df07dd94eb7e5fcdfc45feff43cb5?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"A. Pavlenko\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#webpage\",\"url\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/\",\"name\":\"\\u041f\\u043e\\u0442\\u043e\\u043a\\u0438 \\u0432 Python: threading \\u0438 GIL \\u043d\\u0430 \\u043f\\u0440\\u0430\\u043a\\u0442\\u0438\\u043a\\u0435 | Otus\",\"description\":\"\\u0420\\u0430\\u0437\\u0431\\u0438\\u0440\\u0430\\u0435\\u043c \\u043c\\u043e\\u0434\\u0443\\u043b\\u044c threading \\u0432 Python: \\u0441\\u043e\\u0437\\u0434\\u0430\\u043d\\u0438\\u0435 \\u043f\\u043e\\u0442\\u043e\\u043a\\u043e\\u0432, Lock, \\u0433\\u043e\\u043d\\u043a\\u0438 \\u0434\\u0430\\u043d\\u043d\\u044b\\u0445, GIL \\u0438 \\u043a\\u043e\\u0433\\u0434\\u0430 \\u0434\\u043b\\u044f CPU-bound \\u0437\\u0430\\u0434\\u0430\\u0447 \\u043d\\u0443\\u0436\\u0435\\u043d multiprocessing \\u0432\\u043c\\u0435\\u0441\\u0442\\u043e \\u043f\\u043e\\u0442\\u043e\\u043a\\u043e\\u0432.\",\"inLanguage\":\"ru-RU\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/author\\\/a-pavlenko\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/author\\\/a-pavlenko\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/otus.ru\\\/journal\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/oj-1080x720-14.png\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#mainImage\",\"width\":1080,\"height\":720},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/threads-v-python\\\/#mainImage\"},\"datePublished\":\"2026-09-19T05:32:54+00:00\",\"dateModified\":\"2026-09-25T15:43:34+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/#website\",\"url\":\"https:\\\/\\\/otus.ru\\\/journal\\\/\",\"name\":\"OTUS \\u0416\\u0443\\u0440\\u043d\\u0430\\u043b - \\u0411\\u043b\\u043e\\u0433 \\u043f\\u0440\\u043e IT\",\"alternateName\":\"OTUS \\u0416\\u0443\\u0440\\u043d\\u0430\\u043b\",\"description\":\"\\u0411\\u043b\\u043e\\u0433 \\u043f\\u0440\\u043e IT\",\"inLanguage\":\"ru-RU\",\"publisher\":{\"@id\":\"https:\\\/\\\/otus.ru\\\/journal\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 Python: threading \u0438 GIL \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 | Otus","description":"\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c threading \u0432 Python: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, Lock, \u0433\u043e\u043d\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u044f CPU-bound \u0437\u0430\u0434\u0430\u0447 \u043d\u0443\u0436\u0435\u043d multiprocessing \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432.","canonical_url":"https:\/\/otus.ru\/journal\/threads-v-python\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#article","name":"\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 Python: threading \u0438 GIL \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 | Otus","headline":"\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 Python: threading, GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d multiprocessing","author":{"@id":"https:\/\/otus.ru\/journal\/author\/a-pavlenko\/#author"},"publisher":{"@id":"https:\/\/otus.ru\/journal\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/otus.ru\/journal\/wp-content\/uploads\/2022\/05\/oj-1080x720-14.png","width":1080,"height":720},"datePublished":"2026-09-19T05:32:54+00:00","dateModified":"2026-09-25T15:43:34+00:00","inLanguage":"ru-RU","mainEntityOfPage":{"@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#webpage"},"isPartOf":{"@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#webpage"},"articleSection":"\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0435, Python"},{"@type":"BreadcrumbList","@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/otus.ru\/journal\/#listItem","position":1,"name":"Home","item":"https:\/\/otus.ru\/journal\/","nextItem":{"@type":"ListItem","@id":"https:\/\/otus.ru\/journal\/category\/polza\/#listItem","name":"\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0435"}},{"@type":"ListItem","@id":"https:\/\/otus.ru\/journal\/category\/polza\/#listItem","position":2,"name":"\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0435","item":"https:\/\/otus.ru\/journal\/category\/polza\/","nextItem":{"@type":"ListItem","@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#listItem","name":"\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 Python: threading, GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d multiprocessing"},"previousItem":{"@type":"ListItem","@id":"https:\/\/otus.ru\/journal\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#listItem","position":3,"name":"\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 Python: threading, GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d multiprocessing","previousItem":{"@type":"ListItem","@id":"https:\/\/otus.ru\/journal\/category\/polza\/#listItem","name":"\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0435"}}]},{"@type":"Organization","@id":"https:\/\/otus.ru\/journal\/#organization","name":"\u041e\u0442\u0443\u0441 \u043e\u043d\u043b\u0430\u0439\u043d-\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435","description":"\u0411\u043b\u043e\u0433 \u043f\u0440\u043e IT","url":"https:\/\/otus.ru\/journal\/","telephone":"+74999389202","logo":{"@type":"ImageObject","url":"https:\/\/otus.ru\/journal\/wp-content\/uploads\/2026\/04\/OTUS-journal-logo-180x180-1.png","@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#organizationLogo","width":180,"height":180},"image":{"@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#organizationLogo"},"sameAs":["https:\/\/www.youtube.com\/channel\/UCetgtvy93o3i3CvyGXKFU3g"]},{"@type":"Person","@id":"https:\/\/otus.ru\/journal\/author\/a-pavlenko\/#author","url":"https:\/\/otus.ru\/journal\/author\/a-pavlenko\/","name":"A. Pavlenko","image":{"@type":"ImageObject","@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/13488c7d5b657aaaf1808afd398f71e0225df07dd94eb7e5fcdfc45feff43cb5?s=96&d=mm&r=g","width":96,"height":96,"caption":"A. Pavlenko"}},{"@type":"WebPage","@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#webpage","url":"https:\/\/otus.ru\/journal\/threads-v-python\/","name":"\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 Python: threading \u0438 GIL \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 | Otus","description":"\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c threading \u0432 Python: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, Lock, \u0433\u043e\u043d\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u044f CPU-bound \u0437\u0430\u0434\u0430\u0447 \u043d\u0443\u0436\u0435\u043d multiprocessing \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432.","inLanguage":"ru-RU","isPartOf":{"@id":"https:\/\/otus.ru\/journal\/#website"},"breadcrumb":{"@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#breadcrumblist"},"author":{"@id":"https:\/\/otus.ru\/journal\/author\/a-pavlenko\/#author"},"creator":{"@id":"https:\/\/otus.ru\/journal\/author\/a-pavlenko\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/otus.ru\/journal\/wp-content\/uploads\/2022\/05\/oj-1080x720-14.png","@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#mainImage","width":1080,"height":720},"primaryImageOfPage":{"@id":"https:\/\/otus.ru\/journal\/threads-v-python\/#mainImage"},"datePublished":"2026-09-19T05:32:54+00:00","dateModified":"2026-09-25T15:43:34+00:00"},{"@type":"WebSite","@id":"https:\/\/otus.ru\/journal\/#website","url":"https:\/\/otus.ru\/journal\/","name":"OTUS \u0416\u0443\u0440\u043d\u0430\u043b - \u0411\u043b\u043e\u0433 \u043f\u0440\u043e IT","alternateName":"OTUS \u0416\u0443\u0440\u043d\u0430\u043b","description":"\u0411\u043b\u043e\u0433 \u043f\u0440\u043e IT","inLanguage":"ru-RU","publisher":{"@id":"https:\/\/otus.ru\/journal\/#organization"}}]}},"aioseo_meta_data":{"post_id":"3539","title":"\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 Python: threading \u0438 GIL \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 | Otus","description":"\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c threading \u0432 Python: \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, Lock, \u0433\u043e\u043d\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u044f CPU-bound \u0437\u0430\u0434\u0430\u0447 \u043d\u0443\u0436\u0435\u043d multiprocessing \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432.","keywords":[],"keyphrases":{"focus":[],"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":{"id":"aioseo-article-6363a12ae91aa","slug":"article","graphName":"Article","label":"\u0421\u0442\u0430\u0442\u044c\u044f","properties":{"type":"BlogPosting","name":"#post_title","headline":"#post_title","description":"#post_excerpt","image":"","keywords":"","author":{"name":"#author_name","url":"#author_url"},"dates":{"include":true,"datePublished":"","dateModified":""}}},"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":"{\"article\":{\"articleType\":\"BlogPosting\"},\"course\":{\"name\":\"\",\"description\":\"\",\"provider\":\"\"},\"faq\":{\"pages\":[]},\"product\":{\"reviews\":[]},\"recipe\":{\"ingredients\":[],\"instructions\":[],\"keywords\":[]},\"software\":{\"reviews\":[],\"operatingSystems\":[]},\"webPage\":{\"webPageType\":\"WebPage\"}}","pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","location":null,"local_seo":{"businessInfo":{"name":"","urls":{"website":"","aboutPage":"","contactPage":""},"address":{"line1":"","line2":"","zip":"","city":"","state":"","country":""},"contact":{"email":"","phone":"","fax":""},"ids":{"vatID":"","taxID":"","chamberID":""},"payment":{"priceIndication":"","currenciesAccepted":"","methodsAccepted":""},"areaServed":""},"openingHours":{"show":false,"closedLabel":"","open24h":false,"open24hLabel":"","open247":false,"use24hFormat":false,"twoSets":false,"timezone":"","hours":[]}},"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2022-05-05 19:52:06","updated":"2026-09-25 16:34:14","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/otus.ru\/journal\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/otus.ru\/journal\/category\/polza\/\" title=\"\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0435\">\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0435<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 Python: threading, GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d multiprocessing\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/otus.ru\/journal\/"},{"label":"\u041f\u043e\u043b\u0435\u0437\u043d\u043e\u0435","link":"https:\/\/otus.ru\/journal\/category\/polza\/"},{"label":"\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 Python: threading, GIL \u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d multiprocessing","link":"https:\/\/otus.ru\/journal\/threads-v-python\/"}],"_links":{"self":[{"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/posts\/3539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/comments?post=3539"}],"version-history":[{"count":3,"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/posts\/3539\/revisions"}],"predecessor-version":[{"id":13251,"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/posts\/3539\/revisions\/13251"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/media\/3540"}],"wp:attachment":[{"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/media?parent=3539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/categories?post=3539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/otus.ru\/journal\/wp-json\/wp\/v2\/tags?post=3539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}