{"id":4,"date":"2006-07-27T16:22:59","date_gmt":"2005-03-18T23:48:05","guid":{"rendered":""},"modified":"2017-03-07T15:51:10","modified_gmt":"2017-03-07T15:51:10","slug":"python_sucks","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/agaffney\/2006\/07\/27\/python_sucks\/","title":{"rendered":"Python threading sucks"},"content":{"rendered":"<p>Recently, when testing the installer, we noticed a weird issue. When &#8217;emerge sync&#8217; is run, rsync would complete the sync but not exit, which caused the install to hang. It took 2 days and a lot of frustration to finally track this one down. We owe the answer to d_m (on freenode).<\/p>\n<p>The installer runs with 2 separate threads. The frontend is the main thread and the backend starts up a second thread to run the commands that perform the install. It turns out that when python creates a new thread, it blocks all signals for that thread. I&#8217;m not quite sure why. This has the side effect of blocking all signals for any processes that are fork()ed and\/or exec()ed from that child thread.<\/p>\n<p>Rsync fork()s when it&#8217;s doing it&#8217;s thing. One process waits for a USR2 signal from the other before they mutually exit. Since python had blocked all signals, the signal wasn&#8217;t getting from one process to another so they could exit. d_m&#8217;s solution was to write a small C program that resets the signal mask when running external programs. While this works, it is a huge hack. Although, this bug should be fixed in python 2.4 :-\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, when testing the installer, we noticed a weird issue. When &#8217;emerge sync&#8217; is run, rsync would complete the sync but not exit, which caused the install to hang. It took 2 days and a lot of frustration to finally track this one down. We owe the answer to d_m (on freenode). The installer runs &hellip; <a href=\"https:\/\/blogs.gentoo.org\/agaffney\/2006\/07\/27\/python_sucks\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Python threading sucks<\/span><\/a><\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/agaffney\/wp-json\/wp\/v2\/posts\/4"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/agaffney\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/agaffney\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/agaffney\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/agaffney\/wp-json\/wp\/v2\/comments?post=4"}],"version-history":[{"count":1,"href":"https:\/\/blogs.gentoo.org\/agaffney\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"predecessor-version":[{"id":27,"href":"https:\/\/blogs.gentoo.org\/agaffney\/wp-json\/wp\/v2\/posts\/4\/revisions\/27"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/agaffney\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/agaffney\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/agaffney\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}