Skip to content

Commit

Permalink
use common cleanup, clean flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mschubert committed Aug 11, 2018
1 parent 7100d58 commit 36d7861
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
3 changes: 3 additions & 0 deletions R/qsys.r
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ QSys = R6::R6Class("QSys",
success = self$workers_running == 0
if (!quiet)
private$summary_stats()
if (success)
private$is_cleaned_up = TRUE
success
}
),
Expand Down Expand Up @@ -163,6 +165,7 @@ QSys = R6::R6Class("QSys",
reuse = NULL,
template = NULL,
defaults = list(),
is_cleaned_up = FALSE,

send = function(..., serialize=TRUE) {
rzmq::send.socket(socket = private$socket,
Expand Down
9 changes: 2 additions & 7 deletions R/qsys_lsf.r
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ LSF = R6::R6Class("LSF",
}
},

cleanup = function(quiet=FALSE) {
success = super$cleanup(quiet=quiet)
self$finalize(success)
},

finalize = function(clean=FALSE) {
finalize = function() {
if (!private$is_cleaned_up) {
system(paste("bkill -J", private$job_id),
ignore.stdout=clean, ignore.stderr=clean)
ignore.stdout=FALSE, ignore.stderr=clean)
private$is_cleaned_up = TRUE
}
}
Expand Down
9 changes: 2 additions & 7 deletions R/qsys_sge.r
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ SGE = R6::R6Class("SGE",
}
},

cleanup = function(quiet=FALSE) {
success = super$cleanup(quiet=quiet)
self$finalize(success)
},

finalize = function(clean=FALSE) {
finalize = function() {
if (!private$is_cleaned_up) {
system(paste("qdel", private$job_id),
ignore.stdout=clean, ignore.stderr=clean)
ignore.stdout=FALSE, ignore.stderr=clean)
private$is_cleaned_up = TRUE
}
}
Expand Down
9 changes: 2 additions & 7 deletions R/qsys_slurm.r
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ SLURM = R6::R6Class("SLURM",
}
},

cleanup = function(quiet=FALSE) {
success = super$cleanup(quiet=quiet)
self$finalize(success)
},

finalize = function(clean=FALSE) {
finalize = function() {
if (!private$is_cleaned_up) {
system(paste("scancel --jobname", private$job_id),
ignore.stdout=clean, ignore.stderr=clean)
ignore.stdout=FALSE, ignore.stderr=clean)
private$is_cleaned_up = TRUE
}
}
Expand Down

0 comments on commit 36d7861

Please sign in to comment.