<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Subinterpreters on Shai Asher</title><link>https://slow-is-smooth.io/tags/subinterpreters/</link><description>Recent content in Subinterpreters on Shai Asher</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Sun, 13 Sep 2020 09:00:00 +0300</lastBuildDate><atom:link href="https://slow-is-smooth.io/tags/subinterpreters/index.xml" rel="self" type="application/rss+xml"/><item><title>Fork, Threads and Other Interpreters</title><link>https://slow-is-smooth.io/blog/fork-threads-and-other-interpreters/</link><pubDate>Sun, 13 Sep 2020 09:00:00 +0300</pubDate><guid>https://slow-is-smooth.io/blog/fork-threads-and-other-interpreters/</guid><description>&lt;p&gt;A Python program starts a thread, the thread takes a lock, and the main thread calls &lt;code&gt;os.fork()&lt;/code&gt;.&#10;In the child, the lock is still locked, and the thread that holds it doesn&amp;rsquo;t exist: &lt;code&gt;fork()&lt;/code&gt; copies&#10;the whole address space and exactly one thread, the one that called it. Nothing in the child will ever&#10;release that lock. And if the same program has ever created a subinterpreter and not destroyed it, it&#10;doesn&amp;rsquo;t get that far: on CPython 3.8.5, and on the 3.9 release candidate, the child hangs inside&#10;&lt;code&gt;fork()&lt;/code&gt; itself, on a lock that CPython&amp;rsquo;s own clean-up code takes twice.&lt;/p&gt;</description></item></channel></rss>