Skip to content

Commit

Permalink
Display task description and status
Browse files Browse the repository at this point in the history
  • Loading branch information
kippandrew committed Oct 8, 2013
1 parent c26de41 commit 2e99034
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions R/lucid.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,30 @@ lucidClient <- function(authInfo) {
waitForTaskCompletion = function(taskId, quiet = FALSE) {

path <- paste("/tasks/", taskId, sep="")


cat("Waiting for task: ", taskId, "\n", sep="")

lastStatus <- NULL
while(TRUE) {
# check status
status <- handleResponse(GET(authInfo, path))

# display status to the user if it changed
if (!identical(lastStatus, status$description)) {
if (!quiet)
cat(" ", status$status, ": ", status$description, "\n", sep="")
lastStatus <- status$description
}

# are we finished? (note: this codepath is the only way to exit
# this function)
if (status$finished) {
else if (status$finished) {
if (identical(status$status, "complete"))
return (NULL)
else
stop(status$error, call. = FALSE)
}

# display status to the user if it changed
else if (!identical(lastStatus, status$status)) {
if (!quiet)
cat(" ", status$status, "\n", sep="")
lastStatus <- status$status
}

# wait for 1 second before polling again
Sys.sleep(1)
}
Expand Down

0 comments on commit 2e99034

Please sign in to comment.