summaryrefslogtreecommitdiff
path: root/numpy/fft/helper.py
diff options
context:
space:
mode:
authorLion Krischer <krischer@geophysik.uni-muenchen.de>2016-06-07 09:46:24 +0200
committerLion Krischer <krischer@geophysik.uni-muenchen.de>2016-06-07 21:17:43 +0200
commitb0efcbadd5944d44f56c106dc5bc4571ebcab03e (patch)
tree0b4424c1a6fcf33c04c4a95325551a729841355d /numpy/fft/helper.py
parent175476fec763984573e60485a447978cbcb381c0 (diff)
downloadnumpy-b0efcbadd5944d44f56c106dc5bc4571ebcab03e.tar.gz
BUG: Fix race condition with new FFT cache
There is now a lock around cache accesses ensuring thread safety. The size of a cache entry is now also calculated by summing over all arrays in the list.
Diffstat (limited to 'numpy/fft/helper.py')
-rw-r--r--numpy/fft/helper.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/fft/helper.py b/numpy/fft/helper.py
index 5d51c1a24..11307e270 100644
--- a/numpy/fft/helper.py
+++ b/numpy/fft/helper.py
@@ -281,6 +281,7 @@ class _FFTCache(object):
self._dict.popitem(last=False)
def _check_size(self):
- item_sizes = [_i[0].nbytes for _i in self._dict.values() if _i]
+ item_sizes = [sum(_j.nbytes for _j in _i)
+ for _i in self._dict.values() if _i]
max_size = max(self._max_size_in_bytes, 1.5 * max(item_sizes))
return sum(item_sizes) > max_size