only use multiprocessing if max_workers > 1 (partial revert of f95111ff) #1352
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This was a self-own: in f95111f I tried to be smarter than my past self and changed the criterion when to use the ProcessPool executor –
max_workers > 1(i.e. whetherOCRD_MAX_PARALLEL_PAGESwas requested and the processor implementation supports that)isinstance(workspace.mets, ClientSideOcrdMets)(i.e. whether the workspace can be processed in parallel)But for such important cases like Tensorflow, where (unless you put the model in a singleton background process connected via queues to the page workers) multiprocessing is impossible (because the CUDA context cannot be shared), this is clearly wrong. We have to be able to prohibit in the processor implementation (via
max_workers = 1) multiprocessing.