Auto merge of #396 - pimutils:fix-empty-sync, r=untitaker

Fix hangup on no-op sync

None
This commit is contained in:
Homu 2016-03-28 03:37:04 +09:00
commit 15de73d8fc
2 changed files with 18 additions and 0 deletions

View file

@ -408,3 +408,12 @@ def test_unknown_storage(tmpdir, runner, existing, missing):
"These are the configured storages: ['{existing}']"
.format(missing=missing, existing=existing)
) in result.output
@pytest.mark.parametrize('cmd', ['sync', 'metasync'])
def test_no_configured_pairs(tmpdir, runner, cmd):
runner.write_with_general('')
result = runner.invoke([cmd])
assert result.output == 'critical: Nothing to do.\n'
assert result.exception.code == 5

View file

@ -459,8 +459,17 @@ class WorkerQueue(object):
assert self._workers or not self._queue.unfinished_tasks
ui_worker = click_threading.UiWorker()
self._shutdown_handlers.append(ui_worker.shutdown)
_echo = click.echo
with ui_worker.patch_click():
yield
if not self._workers:
# Ugly hack, needed because ui_worker is not running.
click.echo = _echo
cli_logger.critical('Nothing to do.')
sys.exit(5)
ui_worker.run()
self._queue.join()
for worker in self._workers: