Module threadpool :: Class WorkRequest
[frames | no frames]

Class WorkRequest


A request to execute a callable for putting in the request queue later.

See the module function makeRequests() for the common case where you want to build several WorkRequests for the same callable but with different arguments for each call.


Method Summary
  __init__(self, callable, args, kwds, requestID, callback, exc_callback)
Create a work request for a callable and attach callbacks.

Method Details

__init__(self, callable, args=None, kwds=None, requestID=None, callback=None, exc_callback=None)
(Constructor)

Create a work request for a callable and attach callbacks.

A work request consists of the a callable to be executed by a worker thread, a list of positional arguments, a dictionary of keyword arguments.

A callback function can be specified, that is called when the results of the request are picked up from the result queue. It must accept two arguments, the request object and the results of the callable, in that order. If you want to pass additional information to the callback, just stick it on the request object.

You can also give a callback for when an exception occurs. It should also accept two arguments, the work request and a tuple with the exception details as returned by sys.exc_info().

requestID, if given, must be hashable since it is used by the ThreadPool object to store the results of that work request in a dictionary. It defaults to the return value of id(self).


Generated by Epydoc 2.1 on Fri Jun 23 13:37:22 2006 http://epydoc.sf.net