Skip to content

Commit c21334e

Browse files
authored
Fix plot_fmri_data_example errors on computers with few possibilities (#396)
* fix a better limit * fix possibility when no limit is define [tests skip]
1 parent 437267e commit c21334e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

examples/plot_fmri_data_example.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@
6767
"ignore", message="The provided image has no sform in its header."
6868
)
6969

70-
# Limit the ressoruce use for the example to 5 G.
71-
resource.setrlimit(resource.RLIMIT_AS, (int(5 * 1e9), int(5 * 1e9)))
70+
# Limit the ressoruce use for the example to 5 G or maximum of possible.
71+
limit_5G = int(5 * 1e9)
72+
soft, hard = resource.getrlimit(resource.RLIMIT_AS)
73+
new_soft_limit = limit_5G if soft < 0 else min(limit_5G, soft)
74+
new_hard_limit = limit_5G if hard < 0 else min(limit_5G, hard)
75+
resource.setrlimit(resource.RLIMIT_AS, (new_soft_limit, new_hard_limit))
7276
n_job = 1
7377

7478

0 commit comments

Comments
 (0)