Skip to content

Commit c7563cb

Browse files
committed
cli: Show progress during polling for async jobs
If asyncblock is set to true, prints dots as polling requests are made. When result is obtained, dots are wiped and result is printed. Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent 9a66beb commit c7563cb

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎tools/cli/cloudmonkey/cloudmonkey.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,11 @@ def process_json(response):
266266
command = "queryAsyncJobResult"
267267
requests = {'jobid': jobId}
268268
timeout = int(self.timeout)
269+
pollperiod = 3
269270
while timeout > 0:
271+
progress = int((int(self.timeout) - timeout) / pollperiod ) + 1
272+
print '\r' + '.' * progress,
273+
sys.stdout.flush()
270274
response = process_json(conn.make_request_with_auth(command,
271275
requests))
272276
responsekeys = filter(lambda x: 'response' in x,
@@ -282,9 +286,10 @@ def process_json(response):
282286
jobresult["errortext"])
283287
return
284288
elif jobstatus == 1:
289+
print '\r',
285290
return response
286-
time.sleep(4)
287-
timeout = timeout - 4
291+
time.sleep(pollperiod)
292+
timeout = timeout - pollperiod
288293
logger.debug("job: %s to timeout in %ds" % (jobId, timeout))
289294
self.print_shell("Error:", "Async query timeout for jobid=", jobId)
290295

0 commit comments

Comments
 (0)