diff options
author | Alex Stewart <foogod@gmail.com> | 2014-05-02 10:07:01 -0700 |
---|---|---|
committer | Alex Stewart <foogod@gmail.com> | 2014-05-02 10:07:01 -0700 |
commit | e24486e15f9f71f63bdbc4309bcaf40e70ce7e31 (patch) | |
tree | fe35954a03f18af04aa6d1d767856e9bee46d0bc /numpy/fft | |
parent | a0cf18394d5ce33514fdc37093bd2f65ad4b0dde (diff) | |
download | python-numpy-e24486e15f9f71f63bdbc4309bcaf40e70ce7e31.tar.gz python-numpy-e24486e15f9f71f63bdbc4309bcaf40e70ce7e31.tar.bz2 python-numpy-e24486e15f9f71f63bdbc4309bcaf40e70ce7e31.zip |
Fix for #4655: Make fftpack._raw_fft threadsafe
Diffstat (limited to 'numpy/fft')
-rw-r--r-- | numpy/fft/fftpack.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/fft/fftpack.py b/numpy/fft/fftpack.py index 873249a23..7ee0e4bea 100644 --- a/numpy/fft/fftpack.py +++ b/numpy/fft/fftpack.py @@ -53,10 +53,9 @@ def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti, raise ValueError("Invalid number of FFT data points (%d) specified." % n) try: - wsave = fft_cache[n] - except(KeyError): + wsave = fft_cache.setdefault(n, []).pop() + except (IndexError): wsave = init_function(n) - fft_cache[n] = wsave if a.shape[axis] != n: s = list(a.shape) @@ -77,6 +76,7 @@ def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti, r = work_function(a, wsave) if axis != -1: r = swapaxes(r, axis, -1) + fft_cache[n].append(wsave) return r |