mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Use only one worker if debug mode is activated
This commit is contained in:
parent
f23c79eac9
commit
f0e4cf9ca7
3 changed files with 40 additions and 1 deletions
|
|
@ -18,6 +18,7 @@ Version 0.5.0
|
||||||
- Command line should be a lot faster when no work is done, e.g. for help
|
- Command line should be a lot faster when no work is done, e.g. for help
|
||||||
output.
|
output.
|
||||||
- Fix compatibility with iCloud again.
|
- Fix compatibility with iCloud again.
|
||||||
|
- Use only one worker if debug mode is activated.
|
||||||
|
|
||||||
Version 0.4.4
|
Version 0.4.4
|
||||||
=============
|
=============
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,33 @@ def test_simple_run(tmpdir, runner):
|
||||||
assert tmpdir.join('path_b/haha.txt').read() == 'UID:haha'
|
assert tmpdir.join('path_b/haha.txt').read() == 'UID:haha'
|
||||||
|
|
||||||
|
|
||||||
|
def test_debug_connections(tmpdir, runner):
|
||||||
|
runner.write_with_general(dedent('''
|
||||||
|
[pair my_pair]
|
||||||
|
a = my_a
|
||||||
|
b = my_b
|
||||||
|
|
||||||
|
[storage my_a]
|
||||||
|
type = filesystem
|
||||||
|
path = {0}/path_a/
|
||||||
|
fileext = .txt
|
||||||
|
|
||||||
|
[storage my_b]
|
||||||
|
type = filesystem
|
||||||
|
path = {0}/path_b/
|
||||||
|
fileext = .txt
|
||||||
|
''').format(str(tmpdir)))
|
||||||
|
|
||||||
|
tmpdir.mkdir('path_a')
|
||||||
|
tmpdir.mkdir('path_b')
|
||||||
|
|
||||||
|
result = runner.invoke(['-vdebug', 'sync', '--max-workers=3'])
|
||||||
|
assert 'using 3 maximal workers' in result.output.lower()
|
||||||
|
|
||||||
|
result = runner.invoke(['-vdebug', 'sync'])
|
||||||
|
assert 'using 1 maximal workers' in result.output.lower()
|
||||||
|
|
||||||
|
|
||||||
def test_empty_storage(tmpdir, runner):
|
def test_empty_storage(tmpdir, runner):
|
||||||
runner.write_with_general(dedent('''
|
runner.write_with_general(dedent('''
|
||||||
[pair my_pair]
|
[pair my_pair]
|
||||||
|
|
|
||||||
|
|
@ -48,14 +48,25 @@ def app(ctx, verbosity):
|
||||||
if ctx.obj is None:
|
if ctx.obj is None:
|
||||||
ctx.obj = {}
|
ctx.obj = {}
|
||||||
|
|
||||||
|
ctx.obj['verbosity'] = verbosity
|
||||||
|
|
||||||
if 'config' not in ctx.obj:
|
if 'config' not in ctx.obj:
|
||||||
ctx.obj['config'] = load_config()
|
ctx.obj['config'] = load_config()
|
||||||
|
|
||||||
main = app
|
main = app
|
||||||
|
|
||||||
|
def max_workers_callback(ctx, param, value):
|
||||||
|
if value == 0 and ctx.obj['verbosity'] == log.logging.DEBUG:
|
||||||
|
return 1
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
max_workers_option = click.option(
|
max_workers_option = click.option(
|
||||||
'--max-workers', default=0, type=click.IntRange(min=0, max=None),
|
'--max-workers', default=0, type=click.IntRange(min=0, max=None),
|
||||||
help=('Use at most this many connections, 0 means unlimited.')
|
callback=max_workers_callback,
|
||||||
|
help=('Use at most this many connections. With debug messages enabled, '
|
||||||
|
'the default is 1, otherwise an unlimited amount of connections is '
|
||||||
|
'used.')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue