Skip to content

Commit

Permalink
Adding timeout, adding tries to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagochst committed Mar 8, 2017
1 parent a127704 commit 5b7de31
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ importFrom(grDevices,rainbow)
importFrom(grid,gpar)
importFrom(grid,grid.rect)
importFrom(gridExtra,rbind.gtable)
importFrom(httr,timeout)
importFrom(igraph,"V<-")
importFrom(igraph,E)
importFrom(igraph,V)
Expand Down
2 changes: 1 addition & 1 deletion R/TCGAInternal.R
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ getResults <- function(query, rows, cols){
}


getURL <- function(URL, FUN, ..., N.TRIES=1L) {
getURL <- function(URL, FUN, ..., N.TRIES=3L) {
N.TRIES <- as.integer(N.TRIES)
stopifnot(length(N.TRIES) == 1L, !is.na(N.TRIES))

Expand Down
4 changes: 2 additions & 2 deletions R/TCGAPrepare.R
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,9 @@ getBarcodeInfo <- function(barcode) {
#message(paste0(baseURL,paste(options.pretty,options.expand, option.size, options.filter, sep = "&")))
url <- paste0(baseURL,paste(options.pretty,options.expand, option.size, options.filter, sep = "&"))
json <- tryCatch(
getURL(url,fromJSON,simplifyDataFrame = TRUE),
getURL(url,fromJSON,timeout(600),simplifyDataFrame = TRUE),
error = function(e) {
fromJSON(content(getURL(url,GET), as = "text", encoding = "UTF-8"), simplifyDataFrame = TRUE)
fromJSON(content(getURL(url,GET,timeout(600)), as = "text", encoding = "UTF-8"), simplifyDataFrame = TRUE)
}
)

Expand Down
5 changes: 3 additions & 2 deletions R/TCGAQuery.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#' @return A data frame with the results and the parameters used
#' @importFrom jsonlite fromJSON
#' @importFrom knitr kable
#' @importFrom httr timeout
GDCquery <- function(project,
data.category,
data.type,
Expand Down Expand Up @@ -149,9 +150,9 @@ GDCquery <- function(project,
legacy = legacy)
message("ooo Project: ", proj)
json <- tryCatch(
getURL(url,fromJSON,simplifyDataFrame = TRUE),
getURL(url,fromJSON,timeout(600),simplifyDataFrame = TRUE),
error = function(e) {
fromJSON(content(getURL(url,GET), as = "text", encoding = "UTF-8"), simplifyDataFrame = TRUE)
fromJSON(content(getURL(url,GET,timeout(600)), as = "text", encoding = "UTF-8"), simplifyDataFrame = TRUE)
}
)
json$data$hits$acl <- NULL
Expand Down
4 changes: 2 additions & 2 deletions R/TCGAquery_clinical.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ GDCquery_clinic <- function(project, type = "clinical", save.csv = FALSE){
URLencode('"]}}]}'))
url <- paste0(baseURL,paste(options.pretty,options.expand, option.size, options.filter,"format=json", sep = "&"))
json <- tryCatch(
getURL(url,fromJSON,simplifyDataFrame = TRUE),
getURL(url,fromJSON,timeout(600),simplifyDataFrame = TRUE),
error = function(e) {
fromJSON(content(getURL(url,GET), as = "text", encoding = "UTF-8"), simplifyDataFrame = TRUE)
fromJSON(content(getURL(url,GET,timeout(600)), as = "text", encoding = "UTF-8"), simplifyDataFrame = TRUE)
}
)

Expand Down

0 comments on commit 5b7de31

Please sign in to comment.