Пример #1
0
 def __init__(self, global_queue):
     """
     Initializes the private queue
     :param global_queue: Object of the global Queue
     """
     Queue.__init__(self)
     self.global_queue = global_queue
Пример #2
0
    def __init__(self, maxsize=0, num_workers=1, verbosity=0):
        Queue.__init__(self, maxsize=maxsize)
        self.num_workers = num_workers
        self.verbosity = verbosity
        self.threads = []

        self.start_workers()
Пример #3
0
    def __init__(self, db_base_dir=None, on_scan_complete=None,
                 extra_module_dirs=None, env=None,
                 db_event_reporter=None, db_catalog_dirs=None,
                 db_import_everything_langs=None):
        """Create a CodeIntel manager.

            "db_base_dir" (optional) specifies the base directory for
                the codeintel database. If not given it will default to
                '~/.codeintel'.
            "on_scan_complete" (optional) is a callback for Citadel scan
                completion. It will be passed the ScanRequest instance
                as an argument.
            "extra_module_dirs" (optional) is a list of extra dirs
                in which to look for and use "codeintel_*.py"
                support modules (and "lang_*.py" modules, DEPRECATED).
            "env" (optional) is an Environment instance (or subclass).
                See environment.py for details.
            "db_event_reporter" (optional) is a callback that will be called
                    db_event_reporter(<event-desc-string>)
                before "significant" long processing events in the DB. This
                may be useful to forward to a status bar in a GUI.
            "db_catalog_dirs" (optional) is a list of catalog dirs in
                addition to the std one to use for the CatalogsZone. All
                *.cix files in a catalog dir are made available.
            "db_import_everything_langs" (optional) is a set of langs for which
                the extra effort to support Database
                `lib.hits_from_lpath()' should be made. See class
                Database for more details.
        """
        threading.Thread.__init__(self, name="CodeIntel Manager")
        self.setDaemon(True)
        Queue.__init__(self)

        self.citadel = Citadel(self)

        # Module registry bits.
        self._registered_module_canon_paths = set()
        self.silvercity_lexer_from_lang = {}
        self.buf_class_from_lang = {}
        self.langintel_class_from_lang = {}
        self._langintel_from_lang_cache = {}
        self.import_handler_class_from_lang = {}
        self._is_citadel_from_lang = {
        }  # registered langs that are Citadel-based
        self._is_cpln_from_lang = {
        }  # registered langs for which completion is supported
        self._hook_handlers_from_lang = defaultdict(list)

        self.env = env or DefaultEnvironment()
        # The database must be enabled before registering modules.
        self.db = Database(self, base_dir=db_base_dir,
                           catalog_dirs=db_catalog_dirs,
                           event_reporter=db_event_reporter,
                           import_everything_langs=db_import_everything_langs)

        self.lidb = langinfo.get_default_database()
        self._register_modules(extra_module_dirs)

        self.idxr = indexer.Indexer(self, on_scan_complete)
Пример #4
0
 def __init__(self, id, blocking=False, timeout=None, throwing=False):
     Queue.__init__(self)
     self.id = id
     self.owner = owner
     self.blocking = blocking
     self.timeout = timeout
     self.throwing = throwing
     self.event_handlers = []
Пример #5
0
    def __init__(self, *qargs, **qkeys):
        """Construct an execution queue.

        `qargs` and `qkeys` are passed to the underlying `Queue` object.
        """
        Queue.__init__(self, *qargs, **qkeys)
        self.__current_exec = None
        self.__exec_mutex = threading.Lock()
Пример #6
0
 def __init__(self, workers=1):
     """
     initialize a new Queue
     :param workers: number of workers
     """
     Queue.__init__(self)
     self.workers_count = workers
     self.workers = []
Пример #7
0
    def __init__(self, maxsize=10):
        """
        Class constructor. Instantiates a new :class:`.XBeeQueue` with the provided parameters.

        Args:
            maxsize (Integer, default: 10) the maximum size of the queue.
        """
        Queue.__init__(self, maxsize)
Пример #8
0
 def __init__(self, size):
     Queue.__init__(self, maxsize=size)
     self.logger = self.create_logger()
     self.is_stopped_lock = Lock()
     self.is_stopped = False
     self.is_running_lock = Lock()
     self.is_running = True
     self.thread = None
Пример #9
0
    def __init__(self, config, prefix, producer = True):

        # base class init
        Queue.__init__(self, config, prefix, producer)

        # get other attributes
        self._folder     = config.getMulti(prefix, "folder")
        self._ext        = "." + config.getMulti(prefix, "extension", "bin")
        self._period     = config.getMulti(prefix, "rescan", 5)
        self._pid        = config.getMulti(prefix, "lockfile", "queue.pid")
        self._keep       = config.getMulti(prefix, "keep", False)
        self._errFolder  = config.getMulti(prefix, "errFolder",  "err")
        self._newFolder  = config.getMulti(prefix, "newFolder",  "new")
        self._doneFolder = config.getMulti(prefix, "doneFolder", "done")
        self._workFolder = config.getMulti(prefix, "workFolder", "work")
        self._errFolder  = self._folder + os.sep + self._errFolder
        self._newFolder  = self._folder + os.sep + self._newFolder
        self._doneFolder = self._folder + os.sep + self._doneFolder
        self._workFolder = self._folder + os.sep + self._workFolder
        self._pattern    = re.compile("^[0-9]{20}-[0-9a-fA-F]{12}-[0-9a-fA-F]{8}" + self._ext + "$")

        # only for consumer queue instances, but define for all
        self._seq      = Sequencer(0)
        self._queue    = [ ]

        # check we have a folder
        if self._folder is None:
            raise QueueConfigurationException("Missing folder path for queue [%s]" % prefix)

        # be sure all folders exist
        self._ensureFolder(self._folder)
        if not self._producer:
            self._ensureFolder(self._errFolder)
            self._ensureFolder(self._newFolder)
            self._ensureFolder(self._doneFolder)
            self._ensureFolder(self._workFolder)

        # if a consumer, lock the queue
        if not self._producer:
            # the pid file
            pidfile = self._folder + os.sep + self._pid

            # try locking
            self._lockFile = None
            try:
                self._lockFile = zc.lockfile.LockFile(pidfile)
            except zc.lockfile.LockError:
                raise QueueFolderLockException("Cannot lock queue, pid file [%s]" % pidfile)

        # if there are entries in work, move them to ready
        #
        # NOTE: only if we are consumers
        if not self._producer:
            self._undoWork()

        # if not a producer, scan the queue
        if not self._producer:
            self._rescan()
Пример #10
0
 def __init__(self, **kwargs):
     Queue.__init__(self)
     SchemaConstructor.__init__(self,
                                schema=CONFIG_CREATE_JOB_QUEUE,
                                default_values=self.DEFAULT_VALUES,
                                defined_values=kwargs)
     ARNObject.__init__(self,
                        name=self.jobQueueName,
                        resource="job-queue/" + self.jobQueueName)
Пример #11
0
    def __init__(self, maxsize=BUFFER_SIZE):
        Queue.__init__(self, maxsize)

        self._runlevel = 0
        self._writable_runlevel = 0
        self.on_initialize = noop
        self.on_begin = noop
        self.on_end = noop
        self.on_finalize = noop
Пример #12
0
 def __init__(self, maxsize=0):
     """Constructor
     
     Parameters:
     maxsize -- Maximium size of this Pile
     """
     Queue.__init__(self, maxsize)
     self._tasks = c_int(0)
     self._tasks_lock = Lock()
Пример #13
0
 def __init__(self, name, size=0, threads=-1, profile=False, target=None):
     Queue.__init__(self, size)
     self.name = name
     self.__threads = []
     for i in range(threads):
         th = WorkThread(self, None, ThreadPool.worker, "%s-%d" % (name, i),
                         (target, profile))
         self.__threads.append(th)
         th.start()
Пример #14
0
    def __init__(self, maxsize=0, timeout=None, name=None):
        # extend the base class
        Queue.__init__(self, maxsize)
        self.timeout = timeout
        logger_name = __name__
        self.name = name
        if name is not None:
            logger_name = '{}.{}'.format(logger_name, name)

        self._logger = logging.getLogger(logger_name)
Пример #15
0
 def __init__(self):
     """
     Inits self.
     self.c_callback is the real C-like callback function.
     """
     Event.__init__(self)
     Queue.__init__(self)
     self.c_callback = \
         ctypes.WINFUNCTYPE(ctypes.c_void_p, ctypes.POINTER(ctypes.c_int),
                            ctypes.POINTER(ctypes.c_int))(self.Callbackfunc)
Пример #16
0
 def __init__(self,maxsize=0,autoSetup=True, outstream=None):
     Queue.__init__(self,maxsize)
     EThread.__init__(self, outstream)
     self._queueWait = 1
     self._retryWait = 5
     if autoSetup:
         try:
             self._cleanSetup()
         except Exception as e:
             self._log(e)
Пример #17
0
    def __init__(self, maxsize, timeout=None):
        """ Queue helper class

        Args:
            maxsize (int): Create a queue object with a given maximum size.
            0 means infinite.
            time_out (int, optional): timeout of waiting block in seconds.
            Defaults to None.
        """
        Queue.__init__(self, maxsize)
        self._timeout = timeout
Пример #18
0
    def __init__(self, wbxmlBytes):

        self.bytesDequeued = 0
        self.bytesEnqueued = 0

        Queue.__init__(self)

        for byte in wbxmlBytes:
            self.put(ord(byte))
            self.bytesEnqueued += 1


        logging.debug("Array byte count: %d, enqueued: %d" % (self.qsize(), self.bytesEnqueued))
Пример #19
0
    def __init__(self, wbxmlBytes):

        self.bytesDequeued = 0
        self.bytesEnqueued = 0

        Queue.__init__(self)

        for byte in wbxmlBytes:
            self.put(byte)
            self.bytesEnqueued += 1

        logging.debug("Array byte count: %d, enqueued: %d" %
                      (self.qsize(), self.bytesEnqueued))
Пример #20
0
 def __init__(self, poolType, poolLimit, dbClass, *args, **kwargs):
   """ poolLimit: if elastic, this is the min connection number, otherwise this is the 
       max number of connection """
   self.poolType= self._dbPoolType or poolType
   self.dbClass= self._dbClass or dbClass
   self.args= self._dbArgs or args
   self.kwargs= self._dbKwargs or kwargs
   self.dbifaces= 0
   self.poolLimit= self._dbPoolLimit or poolLimit
   # We Need a Lock because, altough Queue is thread safe,
   # we want a full control on queue size
   self.mpoolingLock= Lock()
   self.dbemployed= []
   Queue.__init__(self)
Пример #21
0
    def __init__(self, size=1, maxjobs=0, worker_factory=default_worker_factory):
        if not isinstance(worker_factory, collections.Callable):
            raise TypeError("worker_factory must be callable")

        self.worker_factory = worker_factory  # Used to build new workers
        self._size = 0  # Number of active workers we have

        # Initialize the Queue
        Queue.__init__(self, maxjobs)  # The queue contains job that are read by workers
        self._jobs = self  # Pointer to the queue, for backwards compatibility with version 0.9.1 and earlier

        # Hire some workers!
        for i in range(size):
            self.grow()
Пример #22
0
        def __init__(self, path, exclude=None):
            class _EH(ProcessEvent):
                def process_default(self, event):
                    _handleEvent(event)

            Queue.__init__(self)
            self._path = path
            self.exclude = exclude or []
            _handleEvent = self.put
            self._wm = WatchManager()
            self._iNotifier = ThreadedNotifier(self._wm, _EH(), timeout=10)
            self._iNotifier.start()
            self.started = False
            self._watch = []
Пример #23
0
    def __init__(self, width=200, height=200):
        Thread.__init__(self)
        Queue.__init__(self)

        self.dims = (width, height)
        self.cam = picamera.PiCamera()
        self.daemon = True

        self.cam.iso = 100
        self.cam.brightness = 40
        self.cam.color_effects = (128, 128)
        self.cam.hflip = True
        self.cam.meter_mode = 'matrix'
        self.cam.shutter_speed = 7500

        sleep(0.5) #wait for camera to update
Пример #24
0
    def __init__(self, name, type):
        """
        This is the default constructor for the class.

        :param name:        The name of the queue
        :param type:        The type of the queue
        :return:
        """

        # Override the base class
        Queue.__init__(self)

        # Set internals
        self.__name = name
        self.__type = type
        return
Пример #25
0
    def __init__(self, path, maxsize=0, chunksize=100, tempdir=None):
        """Create a persistent queue object on a given path.

        The argument path indicates a directory where enqueued data should be
        persisted. If the directory doesn't exist, one will be created. If maxsize
        is <= 0, the queue size is infinite. The optional argument chunksize
        indicates how many entries should exist in each chunk file on disk.

        The tempdir parameter indicates where temporary files should be stored.
        The tempdir has to be located on the same disk as the enqueued data in
        order to obtain atomic operations.
        """

        self.path = path
        self.chunksize = chunksize
        self.tempdir = tempdir
        if self.tempdir:
            if os.stat(self.path).st_dev != os.stat(self.tempdir).st_dev:
                raise ValueError("tempdir has to be located "
                                 "on same path filesystem")

        SyncQ.__init__(self, maxsize)
        self.info = self._loadinfo()
        # truncate head case it contains garbage
        hnum, hcnt, hoffset = self.info['head']
        headfn = self._qfile(hnum)
        if os.path.exists(headfn):
            if hoffset < os.path.getsize(headfn):
                _truncate(headfn, hoffset)
        # let the head file open
        self.headf = self._openchunk(hnum, 'ab+')
        # let the tail file open
        tnum, _, toffset = self.info['tail']
        self.tailf = self._openchunk(tnum)
        self.tailf.seek(toffset)
        # update unfinished tasks with the current number of enqueued tasks
        self.unfinished_tasks = self.info['size']
        # optimize info file updates
        self.update_info = True
Пример #26
0
 def __init__(self):
   Queue.__init__(self)
   self.virgin = True
Пример #27
0
 def __init__(self, application, num_workers=1):
     Queue.__init__(self)
     self.application = application
     self.num_workers = num_workers
     self.processor = Processor(application)
     self.start_workers()
Пример #28
0
 def __init__(self, mc=None, n_slots=None):
     Queue.__init__(self, n_slots)
     if mc is not None:
         self.fill(mc, n_slots)
Пример #29
0
 def __init__(self, constructor, poolsize):
     Queue.__init__(self, poolsize)
     self.constructor = constructor
Пример #30
0
 def __init__(self, notify_func, **kwargs):
     Queue.__init__(self, **kwargs)
     self.notify_func = notify_func
Пример #31
0
 def __init__(self, constructor, poolsize):
     Queue.__init__(self, poolsize)
     self.constructor = constructor
Пример #32
0
 def __init__(self, *args):
     Queue.__init__(self, *args)
Пример #33
0
 def __init__(self, *args, **kwargs):
     Queue.__init__(self, *args, **kwargs)
     self._close_event = Event()
     self._close_event.clear()
Пример #34
0
 def __init__(self):
     Queue.__init__(self, queue='basic')
Пример #35
0
 def __init__(self, *args):
     Queue.__init__(self, *args)  # Queue does not inherit from object (is an old-style class)
     self._all_jobs_submitted = threading.Event()
Пример #36
0
 def __init__(self, maxsize=1000):
     Queue.__init__(self, maxsize=maxsize)
Пример #37
0
 def __init__(self, **kwargs):
     Queue.__init__(self)
Пример #38
0
	def __init__(self):
		""""""
		gtk.GenericTreeModel.__init__(self)
		Queue.__init__(self)
		self.column_types = (gtk.gdk.Pixbuf, str, int, int, int, int)
		self.cache = Cache()
Пример #39
0
 def __init__(self, maxsize=1000):
     """Queue constructor."""
     Queue.__init__(self, maxsize=maxsize)
Пример #40
0
 def __init__(self):
     Queue.__init__(self, queue='work')
Пример #41
0
 def __init__(self, patients=[]):
     Queue.__init__(self, patients)
Пример #42
0
 def __init__(self, f, maxsize=0):
     Queue.__init__(self, maxsize)
     self.queue = []
     self.f = f
Пример #43
0
 def __init__(self, *args, **kwargs):
     Queue.__init__(self, *args, **kwargs)
     self._close_event = Event()
     self._close_event.clear()
Пример #44
0
 def __init__(self, session, destination):
   Queue.__init__(self)
   self.session = session
   self.destination = destination
Пример #45
0
 def __init__(self, maxsize=1000):
     """Queue constructor."""
     Queue.__init__(self, maxsize=maxsize)
Пример #46
0
 def __init__(self, exchange='exchange_001', type='direct'):
     Queue.__init__(self)
     self.channel.exchange_declare(exchange=exchange, type=type)
     self.exchange = exchange
     self.type = type
Пример #47
0
 def __init__(self):
     Queue.__init__(self)
Пример #48
0
 def __init__(self):
     Queue.__init__(self)
     self.patients = []
Пример #49
0
 def __init__(self, **kwargs):
     Queue.__init__(self)
Пример #50
0
 def __init__(self):
     Queue.__init__(self)
     self.all_tasks_done = threading.Condition(self.mutex)
     self.unfinished_tasks = 0