AsynQueue:   Asynchronous task queueing

The foundation for all your task queuing is an instance of TaskQueue, which is imported from the base module. You attach one or more worker objects to the queue and feed it tasks via its call method. The queue will dispatch the tasks to whichever workers are available and qualified to handle them.

You can construct the queue with one or more workers. Alternatively, you can attach them later with its attachWorker method. In that case, you'll receive an ID as the result of the method that you can use to detach the worker.

You can do priority queuing to one or more threads or cluster nodes. With a mix of compute-intensive and high-priority calls on a single CPU, for example, you can queue up the compute-intensive calls with a low priority and the other stuff with higher priorities. However, you will need to chop up your compute-intensive stuff into smaller pieces for this to be helpful. (That's good asynchronous processing practice, generally.) The priority queuing is only effective at deciding which calls to dispatch next, and each thread call is on its own once it is dispatched from the queue. Each call uses an entire thread for its entire duration, and will keep the queue from dispatching anything else to that thread while it's squatting on it, no matter how low-priority it is.