mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Don't use multiprocessing when having one process
This commit is contained in:
parent
f8c2c8f879
commit
6c81fd6fc2
1 changed files with 13 additions and 3 deletions
|
|
@ -201,9 +201,19 @@ def _main(env, file_cfg):
|
||||||
'general': general
|
'general': general
|
||||||
})
|
})
|
||||||
|
|
||||||
from multiprocessing import Pool
|
processes = general.get('processes', 0) or len(actions)
|
||||||
p = Pool(processes=general.get('processes', 0) or len(actions))
|
cli_logger.debug('Using {} processes.'.format(processes))
|
||||||
p.map(_sync_collection, actions)
|
|
||||||
|
if processes == 1:
|
||||||
|
cli_logger.debug('Not using multiprocessing.')
|
||||||
|
_map = map
|
||||||
|
else:
|
||||||
|
cli_logger.debug('Using multiprocessing.')
|
||||||
|
from multiprocessing import Pool
|
||||||
|
p = Pool(processes=general.get('processes', 0) or len(actions))
|
||||||
|
_map = p.map
|
||||||
|
|
||||||
|
_map(_sync_collection, actions)
|
||||||
|
|
||||||
app.register_command('sync', sync_command)
|
app.register_command('sync', sync_command)
|
||||||
app()
|
app()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue