prajnak / img_preprocess

0 stars 0 forks source link

How will you safely close threads in case any exception occurs inside one of the threads? #4

Open prats226 opened 6 years ago

prats226 commented 6 years ago

https://github.com/prajnak/img_preprocess/blob/4a2f843117d47531c4815c1eb8a196c90e29a733/preprocess.py#L83

prajnak commented 6 years ago

the line where we do concurrent.futures.wait() accepts a return_when parameter that will wait till all futures are finished or cancelled. I can also catch all errors in the row_pipeline function and safely continue after logging them. Ideally, we'd have a multi level catch blcok like


catch BOTOSpecificErrors {
    //cancel if this is serious enough
}
catch GenericError {
   // Throw this error as we don't want generic catch all errors ever
}