<p dir="auto">I am building a web app with Flask when I encountered the strangest error.</p>
<p dir="auto"><code class="notranslate">pandas-0.19.2</code> calls in <code class="notranslate">pandas.core.indexing</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# 32-bit floating point machine epsilon
_eps = np.finfo('f4').eps"><pre class="notranslate"><code class="notranslate"># 32-bit floating point machine epsilon
_eps = np.finfo('f4').eps
</code></pre></div>
<p dir="auto">The call never finish in <code class="notranslate">numpy-1.12.0</code> when called from the Apache server environment with <code class="notranslate">mod_wsgi</code> (compiled for <code class="notranslate">Python/3.5.1+</code> and runtime using <code class="notranslate">Python/3.5.2</code>). The code loads properly when run from a normal <code class="notranslate">Python/3.5.2</code> interpreter.</p>
<p dir="auto">The very same code executes properly with <code class="notranslate">pandas-0.18.1</code> and <code class="notranslate">numpy-1.11.1</code> in the same Apache setup.</p>
<p dir="auto">If an application is using multiple embedded sub interpreters that use numpy, there is a possibility that floating point errors can cause the thread to deadlock.  I traced this down to ufunc_object's _error_handler() method where it does NPY_ALLOW_C_API and that freezes on PyGILStateEnsure().  Interestingly, the PyGILState API is allegedly unsafe for applications using sub interpreters, but it works fine as long as long as each sub interpreter is on its own thread.</p>
<p dir="auto">There is a workaround to call numpy.seterr(all='ignore') as that will not even enter the method.  Ideally the print option would also not get the GIL as the GIL should not be needed for that.  In the meantime I added a warning to Jep when it detects an interpreter on the same thread in the hopes of deterring the conditions that can cause this.  I have a test case that illustrates the problem at <a href="https://github.com/mrj0/jep/blob/v3.3.0rc/src/jep/test/numpy/TestNumpyGILFreeze.java">https://github.com/mrj0/jep/blob/v3.3.0rc/src/jep/test/numpy/TestNumpyGILFreeze.java</a></p>
<p dir="auto">This is somewhat related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="20274662" data-permission-text="Title is private" data-url="https://github.com/numpy/numpy/issues/3837" data-hovercard-type="issue" data-hovercard-url="/numpy/numpy/issues/3837/hovercard" href="https://github.com/numpy/numpy/issues/3837">gh-3837</a>.  If you have problems running the test case, you may need to configure the environment variables PATH, LD_LIBRARY_PATH, or LD_PRELOAD depending on your system.</p>