Skip to content

Commit

Permalink
add send_call (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschubert committed Aug 9, 2018
1 parent 02bb0a8 commit 3664b93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/qsys.r
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ QSys = R6::R6Class("QSys",
stop(sQuote(submit_jobs), " must be overwritten")
},

# Evaluate an arbitrary expression on a worker
send_call = function(expr, env=list()) {
private$send(id="DO_CALL", expr=substitute(expr), env=env)
},

# Sets the common data as an rzmq message object
set_common_data = function(...) {
args = lapply(list(...), force)
Expand Down
5 changes: 5 additions & 0 deletions R/worker.r
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ worker = function(master, timeout=600, ..., verbose=TRUE) {
stop("Timeout reached, terminating")

switch(msg$id,
"DO_CALL" = {
result = try(eval(msg$expr, envir=msg$env))
rzmq::send.socket(socket, data=list(id="WORKER_READY",
token=token, expr=msg$expr, result=result))
},
"DO_SETUP" = {
if (!is.null(msg$redirect)) {
data_socket = rzmq::init.socket(zmq_context, "ZMQ_REQ")
Expand Down

0 comments on commit 3664b93

Please sign in to comment.