Logo Search packages:      
Sourcecode: calibre version File versions  Download package

def calibre::utils::threadpool::WorkRequest::__init__ (   self,
  callable,
  args = None,
  kwds = None,
  requestID = None,
  callback = None,
  exc_callback = None 
)

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).

Definition at line 117 of file threadpool.py.

                                       :
        """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).
        """

        if requestID is None:
            self.requestID = id(self)
        else:
            try:
                hash(requestID)
            except TypeError:
                raise TypeError("requestID must be hashable.")
            self.requestID = requestID
        self.exception = False
        self.callback = callback
        self.exc_callback = exc_callback
        self.callable = callable
        self.args = args or []
        self.kwds = kwds or {}


class ThreadPool:


Generated by  Doxygen 1.6.0   Back to index