Skip to content

Commit

Permalink
Include reproducer of joblib#942
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreglaser committed Apr 22, 2020
1 parent 9d3ce9e commit 7bb5f8f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions joblib/test/test_memmapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,28 @@ def test_pool_with_memmap_array_view(factory, tmpdir):
del p


@with_numpy
@parametrize("trial", range(3))
def test_non_regression_memmap_permission_error(trial):
# Smoke test to serve as a non regression test for:
# https://github.com/joblib/joblib/issues/806
#
# The issue happens when trying to delete a memory mapped file that has
# not yet been closed by one of the worker processes.
data = np.random.rand(int(2e6)).reshape((int(1e6), 2))

# Build a complex cyclic reference that is likely to delay garbage
# collection of the memmapped array in the worker processes.
first_list = current_list = [data]
for i in range(10):
current_list = [current_list]
first_list.append(current_list)

results = Parallel(n_jobs=2)(
delayed(len)(current_list) for i in range(10))
assert results == [1] * 10


@with_numpy
@with_multiprocessing
@parametrize("factory", [MemmappingPool, _TestingMemmappingExecutor],
Expand Down

0 comments on commit 7bb5f8f

Please sign in to comment.