tests/testthat/test-multiprocessing.R

test_that("multiprocessing works", {

  skip_if_no_python()

  mp <- import("multiprocessing")
  queue <- mp$Queue()

  for (i in 1:3) {

    expect_no_error({
      p <- mp$Process(target = queue$put,
                      args = tuple(i))
      p$start()
      p$join()
    })

    expect_equal(p$exitcode, 0L)

  }

  expect_equal(queue$get(), 1L)
  expect_equal(queue$get(), 2L)
  expect_equal(queue$get(), 3L)


})

Try the reticulate package in your browser

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

reticulate documentation built on Sept. 11, 2024, 8:31 p.m.