swingutils.threads.threadpool

class swingutils.threads.threadpool.TaskExecutor(coreThreads=1, maxThreads=1, keepalive=5, queue=None)

This is a configurable thread pool for executing background tasks.

Parameters:
  • coreThreads – Minimum number of threads
  • maxThreads – Maximum number of threads
  • keepalive – Time in seconds to keep idle non-core threads alive
  • queue – The queue implementation, defaults to a LinkedBlockingQueue
backgroundTask(func)

This is a decorator wrapper for runBackground().

Return type:AsyncToken
runBackground(func, *args, **kwargs)

Queues a (Python) callable for background execution in this thread pool. Any extra positional and keyword arguments will be passed to the target callable.