Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
351 views
in Technique[技术] by (71.8m points)

debugging - How to figure out which index of Python Multiprocessing function is throwing an exception?

I have an API call that I'm accessing via Python's multiprocessing map. In one of the rows, it's throwing a JSON decoding error but I can't figure out which row. How can I print the index the mapper is working on?

I would like to figure out either which count/index the multiprocess is working on that throws the error or which dataframe row.

def function(a):
    rv = requests.post(
    "url",
    data=json.dumps(literal_eval(a)),
    headers={"Content-Type": "application/json"},
    )  
    proba_json = rv.json()
    proba =  (proba_json['data']['proba'])
    return proba

with mlt.Pool(4) as p:
    df["new_column"] = (p.map(function, df.column))
question from:https://stackoverflow.com/questions/65859624/how-to-figure-out-which-index-of-python-multiprocessing-function-is-throwing-an

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...