bibliopixel.util.threads.sub module

More or less uniformly run something as a new daemon thread or process.

bibliopixel.util.threads.sub.run(function, *args, use_subprocess=False, daemon=True, **kwds)[source]

Create input, output queues, call function in a subprocess or a thread.

function is called like this: function(input, output, *args, **kwds)

Parameters:
  • use_subprocess – if true, create a new multiprocess; if false, create a new thread
  • function – the function to call
  • daemon – is the thread or subprocess run as a daemon or not?
  • args – positional arguments to the function
  • kwds – keyword arguments to the function
Returns:

a tuple with three elements: the subprocess or thread, an input queue, and an output queue.