Skip to content

Commit a53fe9b

Browse files
committed
fix: finished cleaning up errors
1 parent 18f826e commit a53fe9b

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

nipype/pipeline/plugins/tests/test_multiproc_nondaemon.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@
66
import nipype.pipeline.engine as pe
77
from nipype.interfaces.utility import Function
88

9-
def dummyFunction(filename):
10-
'''
11-
This function writes the value 45 to the given filename.
12-
'''
13-
j = 0
14-
for i in range(0, 10):
15-
j += i
16-
17-
# j is now 45 (0+1+2+3+4+5+6+7+8+9)
18-
19-
with open(filename, 'w') as f:
20-
f.write(str(j))
219

2210
def mytestFunction(insum=0):
2311
'''
@@ -41,6 +29,19 @@ def mytestFunction(insum=0):
4129
# list of tempFiles
4230
f = [None] * numberOfThreads
4331

32+
def dummyFunction(filename):
33+
'''
34+
This function writes the value 45 to the given filename.
35+
'''
36+
j = 0
37+
for i in range(0, 10):
38+
j += i
39+
40+
# j is now 45 (0+1+2+3+4+5+6+7+8+9)
41+
42+
with open(filename, 'w') as f:
43+
f.write(str(j))
44+
4445
for n in xrange(numberOfThreads):
4546

4647
# mark thread as alive
@@ -72,7 +73,7 @@ def mytestFunction(insum=0):
7273
# here, all processes are done
7374

7475
# read in all temp files and sum them up
75-
total = 0
76+
total = insum
7677
for file in f:
7778
with open(file) as fd:
7879
total += int(fd.read())
@@ -105,7 +106,7 @@ def run_multiproc_nondaemon_with_flag(nondaemon_flag):
105106
pipe.base_dir = os.getcwd()
106107
f1.inputs.insum = 0
107108

108-
pipe.config = {'execution': {'stop_on_first_error': True}}
109+
pipe.config = {'execution': {'stop_on_first_crash': True}}
109110
# execute the pipe using the MultiProc plugin with 2 processes and the non_daemon flag
110111
# to enable child processes which start other multiprocessing jobs
111112
execgraph = pipe.run(plugin="MultiProc",
@@ -117,8 +118,7 @@ def run_multiproc_nondaemon_with_flag(nondaemon_flag):
117118
result = node.get_output('sum_out')
118119
os.chdir(cur_dir)
119120
rmtree(temp_dir)
120-
if nondaemon_flag:
121-
yield assert_equal, result, 180 # n_procs (2) * numberOfThreads (2) * 45 == 180
121+
return result
122122

123123

124124
def test_run_multiproc_nondaemon_false():
@@ -130,15 +130,15 @@ def test_run_multiproc_nondaemon_false():
130130
non_daemon flag is on.
131131
'''
132132
shouldHaveFailed = False
133-
134133
try:
135-
# with nondaemon_flag = False, the execution should fail
136-
run_multiproc_nondaemon_with_flag(False)
134+
# with nondaemon_flag = False, the execution should fail
135+
run_multiproc_nondaemon_with_flag(False)
137136
except:
138-
shouldHaveFailed = True
137+
shouldHaveFailed = True
139138
yield assert_true, shouldHaveFailed
140139

141140
def test_run_multiproc_nondaemon_true():
142141
# with nondaemon_flag = True, the execution should succeed
143-
run_multiproc_nondaemon_with_flag(True)
144-
142+
result = run_multiproc_nondaemon_with_flag(True)
143+
yield assert_equal, result, 180 # n_procs (2) * numberOfThreads (2) * 45 == 180
144+

0 commit comments

Comments
 (0)