cwltool.task_queue
==================

.. py:module:: cwltool.task_queue

.. autoapi-nested-parse::

   TaskQueue.



Classes
-------

.. autoapisummary::

   cwltool.task_queue.TaskQueue


Module Contents
---------------

.. py:class:: TaskQueue(lock, thread_count)

   A TaskQueue class.

   Uses a first-in, first-out queue of tasks executed on a fixed number of
   threads.

   New tasks enter the queue and are started in the order received,
   as worker threads become available.

   If thread_count == 0 then tasks will be synchronously executed
   when add() is called (this makes the actual task queue behavior a
   no-op, but may be a useful configuration knob).

   The thread_count is also used as the maximum size of the queue.

   The threads are created during TaskQueue initialization.  Call
   join() when you're done with the TaskQueue and want the threads to
   stop.


   .. py:attribute:: in_flight
      :type:  int
      :value: 0


      The number of tasks in the queue.



   .. py:attribute:: thread_count


   .. py:attribute:: task_queue
      :type:  queue.Queue[collections.abc.Callable[[], None] | None]


   .. py:attribute:: task_queue_threads
      :value: []



   .. py:attribute:: lock


   .. py:attribute:: error
      :type:  BaseException | None
      :value: None



   .. py:method:: add(task, unlock = None, check_done = None)

      Add your task to the queue.

      The optional unlock will be released prior to attempting to add the
      task to the queue.

      If the optional "check_done" threading.Event's flag is set, then we
      will skip adding this task to the queue.

      If the TaskQueue was created with thread_count == 0 then your task will
      be synchronously executed.




   .. py:method:: drain()

      Drain the queue.



   .. py:method:: join()

      Wait for all threads to complete.



