Register that workers are expected. This generates a key that one or more workers will write to when they start up (as used by rrq_worker_spawn).

rrq_worker_expect(obj, worker_ids)

rrq_worker_expect2(worker_ids, controller = NULL)

rrq_worker_wait(obj, key_alive, timeout = Inf, poll = 1, progress = NULL)

rrq_worker_wait2(
  key_alive,
  timeout = Inf,
  poll = 1,
  progress = NULL,
  controller = NULL
)

Arguments

obj

A rrq_controller object

worker_ids

Ids of expected workers

controller

The controller to use. If not given (or NULL) we'll use the controller registered with rrq_default_controller_set().

key_alive

A key as returned by rrq_worker_expect

timeout

Number of seconds to wait for workers to appear. If they have not appeared by this time, we throw an error.

poll

Poll interval, in seconds. Must be an integer

progress

Optional logical indicating if a progress bar should be displayed. If NULL we fall back on the value of the global option rrq.progress, and if that is unset display a progress bar if in an interactive session.

Value

  • For rrq_worker_expect: A string, which can be passed through as the second argument to rrq_worker_wait in order to block until workers are available.

  • For rrq_worker_wait: Invisibly a difftime object with the time spent waiting.

Details

The general pattern here is that the process that submits the worker (so the parent process, or the user submitting a cluster job) would run this function to register that some number of workers will be started at some point in the future. In the case of starting workers by submitting them to a cluster, this could take a long time as the job queues, or if starting by running another process it could be very quick. Information about the workers that are expected and where to find them is stored against a key, which is returned by rrq_worker_expect.

Then, to wait on a set of workers, you run rrq_worker_wait