R/close.R

Defines functions close.rscalaBridge

Documented in close.rscalaBridge

#' Close a Scala Bridge
#'
#' @param con A Scala bridge.
#' @param ... Currently ignored.
#'
#' @return Returns \code{NULL}, invisibly.
#' @export
#'
close.rscalaBridge <- function(con, ...) {
  details <- if ( inherits(con,"rscalaBridge") ) attr(con,"details") else con
  if ( details[["closed"]] ) return(invisible())
  assign("closed",TRUE,envir=details)
  unlink(details[["sessionFilename"]])
  if ( identical(.Platform$OS.type,"windows") && ( ! interactive() ) ) {
    Sys.sleep(15)
  }
  if ( ! details[["disconnected"]] ) {
    tryCatch( close(details[["socketIn"]]  ), error=function(e) NULL )
    tryCatch( close(details[["socketOut"]] ), error=function(e) NULL )
  }
  invisible()
}

Try the rscala package in your browser

Any scripts or data that you put into this service are public.

rscala documentation built on Aug. 15, 2023, 9:07 a.m.