Conditions | 3 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | """Parallel processing functionality for Annif""" |
||
36 | def get_pool(n_jobs): |
||
37 | """return a suitable multiprocessing pool class, and the correct jobs |
||
38 | argument for its constructor, for the given amount of parallel jobs""" |
||
39 | |||
40 | if n_jobs < 1: |
||
41 | n_jobs = None |
||
42 | pool_class = multiprocessing.Pool |
||
43 | elif n_jobs == 1: |
||
44 | # use the dummy wrapper around threading to avoid subprocess overhead |
||
45 | pool_class = multiprocessing.dummy.Pool |
||
46 | else: |
||
47 | pool_class = multiprocessing.Pool |
||
48 | |||
49 | return n_jobs, pool_class |
||
50 |