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

__license__   = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'

Define a threaded interface for working with devices.

import threading, Queue

00012 class DeviceManager(object):

    def __init__(self):
        self.devices = []
        self.device_jobs = Queue(0)

00019 class Job(object):
    count = 0
    def __init__(self, func, args):
        self.completed = False
        self.exception = None

00026 class Worker(threading.Thread):

    def __init__(self, jobs):
        self.jobs = jobs
        self.results = []

00034     def run(self):
        '''Thread loops taking jobs from the queue as they become available'''
        while True:
            self.jobs.get(True, None)
            # Do job

Generated by  Doxygen 1.6.0   Back to index