mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Use multiple connections when syncing.
This commit is contained in:
parent
d7b58d21dd
commit
f8c2c8f879
2 changed files with 36 additions and 15 deletions
|
|
@ -5,6 +5,12 @@
|
||||||
# A folder where vdirsyncer can store some metadata about each pair.
|
# A folder where vdirsyncer can store some metadata about each pair.
|
||||||
status_path = ~/.vdirsyncer/status/
|
status_path = ~/.vdirsyncer/status/
|
||||||
|
|
||||||
|
# The amount of processes to use when synchronizing. If the CPU of your server
|
||||||
|
# is the bottleneck (which is plausible for small homeservers), set this to the
|
||||||
|
# number of cores * 2. Defaults to one process for each collection. The value
|
||||||
|
# 0 will be ignored.
|
||||||
|
#processes =
|
||||||
|
|
||||||
# CONTACTS
|
# CONTACTS
|
||||||
[pair bob_contacts]
|
[pair bob_contacts]
|
||||||
# Similar to accounts in OfflineIMAP.
|
# Similar to accounts in OfflineIMAP.
|
||||||
|
|
|
||||||
|
|
@ -190,10 +190,32 @@ def _main(env, file_cfg):
|
||||||
config_a.update(all_storages[a_name])
|
config_a.update(all_storages[a_name])
|
||||||
config_b = dict(storage_defaults)
|
config_b = dict(storage_defaults)
|
||||||
config_b.update(all_storages[b_name])
|
config_b.update(all_storages[b_name])
|
||||||
|
|
||||||
|
|
||||||
|
actions.append({
|
||||||
|
'config_a': config_a,
|
||||||
|
'config_b': config_b,
|
||||||
|
'pair_name': pair_name,
|
||||||
|
'collection': collection,
|
||||||
|
'pair_options': pair_options,
|
||||||
|
'general': general
|
||||||
|
})
|
||||||
|
|
||||||
|
from multiprocessing import Pool
|
||||||
|
p = Pool(processes=general.get('processes', 0) or len(actions))
|
||||||
|
p.map(_sync_collection, actions)
|
||||||
|
|
||||||
|
app.register_command('sync', sync_command)
|
||||||
|
app()
|
||||||
|
|
||||||
|
def _sync_collection(x):
|
||||||
|
return sync_collection(**x)
|
||||||
|
|
||||||
|
def sync_collection(config_a, config_b, pair_name, collection, pair_options,
|
||||||
|
general):
|
||||||
a = storage_instance_from_config(config_a)
|
a = storage_instance_from_config(config_a)
|
||||||
b = storage_instance_from_config(config_b)
|
b = storage_instance_from_config(config_b)
|
||||||
|
|
||||||
def x(a=a, b=b, pair_name=pair_name, collection=collection):
|
|
||||||
status_name = \
|
status_name = \
|
||||||
'_'.join(filter(bool, (pair_name, collection)))
|
'_'.join(filter(bool, (pair_name, collection)))
|
||||||
pair_description = \
|
pair_description = \
|
||||||
|
|
@ -203,10 +225,3 @@ def _main(env, file_cfg):
|
||||||
sync(a, b, status,
|
sync(a, b, status,
|
||||||
pair_options.get('conflict_resolution', None))
|
pair_options.get('conflict_resolution', None))
|
||||||
save_status(general['status_path'], status_name, status)
|
save_status(general['status_path'], status_name, status)
|
||||||
actions.append(x)
|
|
||||||
|
|
||||||
for action in actions:
|
|
||||||
action()
|
|
||||||
|
|
||||||
app.register_command('sync', sync_command)
|
|
||||||
app()
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue