On 07/12/2007, <b class="gmail_sendername">Sean Reifschneider</b> &lt;<a href="mailto:jafo-python-dev@tummy.com">jafo-python-dev@tummy.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thu, Dec 06, 2007 at 10:55:12PM -0700, Adam Olsen wrote:<br>&gt;That&#39;s pretty much what issue1564547 does.&nbsp;&nbsp;I think there&#39;s two marks<br><br>Good point, I hadn&#39;t seen that before.<br><br>&gt;* Using poll and fd&#39;s is pretty platform specific for what should be a
<br>&gt;general-purpose API<br><br>I would say that this is an optimization that helps a specific set of<br>platforms, including one that I think we really care about, the OLPC which<br>needs it for decreased battery use.&nbsp;&nbsp;It doesn&#39;t cause breakage of
<br>other platforms, it just may not help them.</blockquote><div><br>Not only that, but current python signal handling is not theorethically async safe; there are race conditions in the Py_AddPendingCalls API, and it just happens to work most of the time.
<br><br>BTW, the problem is described here: <a href="http://mail.python.org/pipermail/python-dev/2006-September/068569.html">http://mail.python.org/pipermail/python-dev/2006-September/068569.html</a><br><br>Think of even python 
select.poll and multiple threads.&nbsp; If you have dozens of threads, each blocked in some system call, when a signal arrives it will interrupt one of the system calls, causing it to return EINTR, and then python checks for signals.&nbsp; Now imagine all the non-main threads are not created by python; then one of the threads that wakes up could very well be non-python one, and so python will never realize a signal was delivered.
<br></div></div><br>The solution of blocking signals in all but the python thread(s) is not feasible as we cannot control all threads that are created, some are created by C libraries...<br><br>-- <br>Gustavo J. A. M. Carneiro
<br>INESC Porto, Telecommunications and Multimedia Unit<br>&quot;The universe is always one step beyond logic.&quot; -- Frank Herbert