Get rid of the nested lambda functions to simplify the code.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
-def run_killable(cmd, stdout, killfuncs, kill_fn):
- '''Run a killable program. Returns program retcode or -1 if we can't start it.'''
+def run_killable(cmd, stdout, killfuncs):
+ '''Run a killable program. Returns program retcode or -1 if we can't
+ start it.'''
try:
proc = subprocess.Popen(cmd, stdout = stdout)
try:
proc = subprocess.Popen(cmd, stdout = stdout)
- real_kill_fn = lambda: kill_fn(proc)
- killfuncs.add(real_kill_fn)
+ killfuncs.add(proc.terminate)
- remove_killfunc(killfuncs, real_kill_fn)
+ remove_killfunc(killfuncs, proc.terminate)
return proc.returncode
except:
return -1
return proc.returncode
except:
return -1
cmd = ['@sbindir@/xfs_scrub']
cmd += '@scrub_args@'.split()
cmd += [mnt]
cmd = ['@sbindir@/xfs_scrub']
cmd += '@scrub_args@'.split()
cmd += [mnt]
- ret = run_killable(cmd, None, killfuncs, \
- lambda proc: proc.terminate())
+ ret = run_killable(cmd, None, killfuncs)
if ret >= 0:
print("Scrubbing %s done, (err=%d)" % (mnt, ret))
sys.stdout.flush()
if ret >= 0:
print("Scrubbing %s done, (err=%d)" % (mnt, ret))
sys.stdout.flush()