简体   繁体   中英

Error: [Errno 32] Broken pipe in python code

I am trying to compile this python code in Ubuntu 12.04.

import numpy as np
import argparse
parser = argparse.ArgumentParser(add_help=True)
parser.register('type', 'bool',
       lambda v: v.lower() in ("yes", "true", "t", "1"))
parser.add_argument("-multi", type="bool", action="store",
           default=False, help="True output a single command")
parser.add_argument("-db_host", type=str, action="store",
           default="localhost",
           help="True output a single command")
parser.add_argument("-qoi_ex", type=str, action="store",
           default="v",
           help="Example")
parser.add_argument("-qoi_factor", type=float, default="1",
           action="store", help="QoI scaling factor")
parser.add_argument("-use_rs", type=bool, default="False",
           action="store", help="Use reaction splitting method")
args = parser.parse_known_args()[0]
# Note that 0.6931 is np.log(2)
base = "run.py -mimc_TOL {TOL} -mimc_max_TOL 0.5  \
       -qoi_seed {seed} -mimc_M0 30 -qoi_ex {ex} -qoi_factor {factor}   -use_rs True \
       -mimc_dim 1 -mimc_w 1 -mimc_s 1 -mimc_gamma 1 -mimc_beta 2    -mimc_moments 4 \
       -mimc_bayesian {bayesian} "
cmd_multi = "python " + base + "-mimc_verbose False -db True           
            -db_tag {tag} " + " -db_host {} ".format(args.db_host)
cmd_single = "python " + base + " -mimc_verbose True -db False "
tagr = lambda x: "rs" if x else "tl"
if not args.multi:
    print(cmd_single.format(seed=0, bayesian=True, TOL=0.01, ex=args.qoi_ex, factor=args.qoi_factor))
else:
    realizations = 10
    TOLs = np.sqrt(2.)**-np.arange(5., 12.)
    for TOL in TOLs:
        for i in range(0, realizations):
            print cmd_multi.format(bayesian=True, tag="TL_"+args.qoi_ex+"_"+tagr(args.use_rs), TOL=TOL,  seed=np.random.randint(2**32-1), ex=args.qoi_ex, factor=args.qoi_factor)

But I am getting this error message that I did not know how to fix. I am not sure if the parallelization procedure is causing the problem.

./echo_test_cmd.py -multi True | parallel -j15 Traceback (most recent call last): File "./echo_test_cmd.py", line 43, in print cmd_multi.format(bayesian=True, tag="TL_"+args.qoi_ex+"_"+tagr(args.use_rs), TOL=TOL, seed=np.random.randint(2**32-1), ex=args.qoi_ex, factor=args.qoi_factor) IOError: [Errno 32] Broken pipe

Could anyone help? thanks.

Rebooting and re-installing the parallel tools package solved the problem. Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM