Addon Details

Watch - Add Favorite


ThreadPool ScreenShot

3 out of 3 users claim this version works for them.
Does this version work for you?
9
w00ts
w00t!2

ThreadPool - Version 1

posted on 2011-06-19 12:07:52
by SuperDave



Description

ThreadPool provides a high-level interface with threads. [b]Unlike common threading, ThreadPool threads are simple, reliable, and only in existence when they are being utilized.[/b] [code] ThreadPool provides a high-level interface with threads. * A basic understanding of threads is suggested: http://en.wikipedia.org/wiki/Thread_(computer_science) http://en.wikipedia.org/wiki/Thread_pool_pattern * ONLY INTERACT WITH THE SERVER IN THE MAIN THREAD! NO es MODULE COMMANDS SHOULD BE EXECUTED IN A SEPARATE THREAD * Suggested method of import is: from threadpool import * *** The following decorators are imported using the "all" import (above): *** @threaded(pool_size=1) " This decorator is used to create a ThreadPool instance for a function The function following this decorator will always be executed in a separate thread Any return values of the function are ignored " pool_size = maximum number of simultaneous threads to create *** The following functions are imported using the "all" import: *** threadSafeCall(callback, a=(), kw={}) " Sends the callback function to a queue to be executed the next time the main thread has control " callback = function to be executed a = arguments to pass to the function (tuple) kw = keywords to pass to the function (dictionary) *** The following classes are imported using the "all" import: *** ThreadPool(target, pool_size=1) " Interface for thread pools. Each instance is a new pool. " target = function to execute in separate threads pool_size = maximum number of simultaneous threads to create ThreadPool.push(*a, **kw) " Places the passed arguments and keywords on the queue to be sent to the target function This will execute in a separate thread: target(*a, **kw) " ThreadPool.__call__(*a, **kw) " Substitute for ThreadPool.push, ThreadPool instances can be called directly with data to be pushed to a thread " ThreadPool.setPoolSize(count) " Sets the maximum simultaneous thread count Required threads are created immediately to fit remaining tasks, extraneous threads die when their current task finishes " count = maximum number of simultaneous threads to create ThreadPool.getTaskCount(): " Returns the number of elements (tasks) left on the data queue " Lock() " threading.RLock renamed http://docs.python.org/library/threading.html#rlock-objects "[/code]

Installation

Install with:[syntax="es"]es_install threadpool[/syntax]

Version Notes For 1

Updated on: 2011-06-19 12:07:52 EST by SuperDave (View Zip Contents)
-Initial release

( Previous Versions )