Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:
displayName: 'Check installed packages'
- powershell: |
cd testsuite
pytest MDAnalysisTests --disable-pytest-warnings -n logical --timeout=200 -rsx --cov=MDAnalysis
pytest MDAnalysisTests --disable-pytest-warnings -n logical --timeout=200 -rsx --cov=MDAnalysis --durations=50
displayName: 'Run MDAnalysis Test Suite'
- script: |
curl -s https://codecov.io/bash | bash
Expand Down
29 changes: 20 additions & 9 deletions testsuite/MDAnalysisTests/parallelism/test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,19 @@ def cog(u, ag, frame_id):

def test_multiprocess_COG(u):
ag = u.atoms[2:5]

ref = np.array([cog(u, ag, i) for i in range(3)])

p = multiprocessing.Pool(2)
res = np.array([p.apply(cog, args=(u, ag, i)) for i in range(3)])
p.close()
# Explicitly use `spawn` for multiprocessing tests
# As `fork` can lead to deadlock in pytest because each xdist worker creates a multiprocessing.Pool.
# related issue: #5191; PR #5213
ctx = multiprocessing.get_context("spawn")
# The commented code can lead to timeout that is not marked as a failure due.
# p = multiprocessing.Pool(2)
# res = np.array([p.apply(cog, args=(u, ag, i)) for i in range(3)])
# p.close()
with ctx.Pool(2) as p:
res = np.array(p.starmap(cog, [(u, ag, i) for i in range(3)]))

assert_equal(ref, res)


Expand All @@ -147,10 +154,11 @@ def test_universe_unpickle_in_new_process():
u = mda.Universe(GRO, XTC)
ref = [getnames(u, i) for i in range(3)]

p = multiprocessing.Pool(2)
res = [p.apply(getnames, args=(u, i)) for i in range(3)]
p.close()

# related issue: #5191; PR #5213
ctx = multiprocessing.get_context("spawn")
with ctx.Pool(2) as p:
res = [p.apply_async(getnames, args=(u, i)) for i in range(3)]
res = [r.get() for r in res]
assert_equal(ref, res)


Expand All @@ -162,7 +170,10 @@ def test_creating_multiple_universe_without_offset(temp_xtc, ncopies=3):
# a problem (see PR #3375 and issues #3230, #1988)

args = (GRO, str(temp_xtc))
with multiprocessing.Pool(2) as p:

# related issue: #5191; PR #5213
ctx = multiprocessing.get_context("spawn")
with ctx.Pool(2) as p:
universes = [p.apply_async(mda.Universe, args) for i in range(ncopies)]
universes = [universe.get() for universe in universes]

Expand Down
Loading