Remove 'starting' message for long running operations (#767)

* Remove 'starting' message for long running operations

* Change name of poll_interval_ms as ambiguous and also change logger messages that referred to this interval
This commit is contained in:
Derek Bekoe 2016-08-26 15:08:55 -07:00 коммит произвёл GitHub
Родитель 975904d959
Коммит 8000d63ea9
1 изменённых файлов: 4 добавлений и 8 удалений

Просмотреть файл

@ -4,7 +4,6 @@
#---------------------------------------------------------------------------------------------
from __future__ import print_function
import sys
import json
import time
import traceback
@ -84,21 +83,18 @@ class CliCommandArgument(object):
class LongRunningOperation(object): #pylint: disable=too-few-public-methods
def __init__(self, start_msg='', finish_msg='', poll_interval_ms=1000.0):
def __init__(self, start_msg='', finish_msg='', poller_done_interval_ms=1000.0):
self.start_msg = start_msg
self.finish_msg = finish_msg
self.poll_interval_ms = poll_interval_ms
self.poller_done_interval_ms = poller_done_interval_ms
def _delay(self):
time.sleep(self.poll_interval_ms / 1000.0)
time.sleep(self.poller_done_interval_ms / 1000.0)
def __call__(self, poller):
print(self.start_msg, file=sys.stderr)
logger.info("Starting long running operation '%s' with polling interval %s ms",
self.start_msg, self.poll_interval_ms)
logger.info("Starting long running operation '%s'", self.start_msg)
while not poller.done():
self._delay()
logger.info("Long running operation '%s' polling now", self.start_msg)
try:
result = poller.result()
except ClientException as client_exception: