Class CPythonSpawner

java.lang.Object
nz.org.riskscape.cpython.CPythonSpawner

public class CPythonSpawner extends Object

Handles spawning child CPython processes.

  • Constructor Details

    • CPythonSpawner

      public CPythonSpawner(CPythonSettings settings, nz.org.riskscape.problem.ProblemSink problemSink)
  • Method Details

    • startWrapperScript

      public CPythonSpawner.CPythonProcess startWrapperScript(Object errorContext, nz.org.riskscape.engine.resource.Resource userScript, String... scriptArgs)

      Starts cpython process that wraps a user's python script so that it can start accepting function calls

      Parameters:
      errorContext - context for an error message.
      userScript - the user's code to execute
      scriptArgs - arguments that get given to the script - these will get picked up by the adaptor script to prime the serialization
    • checkForOutputAndWait

      public void checkForOutputAndWait()

      Blocks the calling thread until there's been a full loop of the reaper thread. This is a good way to ensure that any stderr output or processes have been reaped before doing something

    • checkForOutput

      public void checkForOutput()

      A Non-blocking version of checkForOutputAndBlock. Wakes up the reaper thread, but doesn't wait for a check before returning

    • killAll

      public void killAll()

      Forcibly destroy all the processes under our care.

    • destroy

      public void destroy()

      Destroys this spawner by stopping the reaper thread, killing all of the child processes and then waiting for the reaper to exit. You can't use the spawner again.

    • getSettings

      public CPythonSettings getSettings()