runThreads - noetl/noetl GitHub Wiki

E.g. exitCode = runThreads(stepInstance, cursorQueue)

Parameters

  • step: step instance
  • cursorQueue: Queue of cursor queues, populated with strings of the form: task.taskName.step.stepName.cur.cursor

Key Variables

  • exitCode: 0 if the function executed successfully, -1 if it failed
  • thid: thread id
  • th: Thread instance

Functionality

  • RunThreads runs a certain number of cursors, determined by the number of threads (the size of the cursorQueue), in parallel.
  • RunThreads instantiates a Thread object with the target function runQueue (runQueue is called on the arguments when the Thread object's run() function is executed). The Thread is set to be a daemon thread, meaning the program exits when only daemon threads are left. Daemon threads are stopped at shutdown.
  • The Thread's activity is started, which invokes the run() method on the processes in the queue and runs them in parallel. The queue joins the processes before returning out of the function.

Except Statement

If an error arises, the except block prints the time and the error message, and sets the exitCode to -1.

Return Value

Returns the exitCode.