I'm pleased to announce the release of threadpool.py, released under the GNU LGPL. Threadpool.py can be obtained from: http://sourceforge.net/projects/xoltar-toolkit/ and requires the functional.py module available from the same page, or you can download the combined toolkit. This module uses the threading and Queue modules to create a pool of reusable threads. Version 0.8 is a major rewrite of the version previously available from my Python Starship page. It now supports a much cleaner interface, thanks to functional.py. After creating an instance of ThreadPool, one queues functions to be executed. The pool dispatches the functions to the waiting threads, which call them. When queuing a function on the pool with *pool*.put(), an instance of ReturnValue is returned. ReturnValue is a subclass of functional.Lazy, and can be used in any context that a regular lazy expression can. When evaluating a ReturnValue, the evaluating thread will block until the other thread has completed its work and loaded the return value of the function into the ReturnValue instance. VLocks are an alternative to RLocks which include a visible queue threads waiting for the lock. lock, unlock, getLockFor, and deleteLockFor work with a module level dictionary of objects to locks, and can be more convenient than working with lock objects directly. Locked and Async are callable wrappers around a function. Async calls return immediately after queuing their function on a thread pool, while Locked calls first acquire the lock they were passed on creation, call their function, and release the lock. -- Bryn Keller xoltar@starship.python.net
participants (1)
-
Bryn Keller