예제 #1
0
    def __init__(self):
        BuiltinCore.__init__(self)

        #: A dict of child name -> one end of the
        #: :class:`multiprocessing.Pipe` object used to communicate
        #: with that child.  (The child is given the other end of the
        #: Pipe.)
        self.pipes = dict()

        #: A queue that keeps track of which children are available to
        #: render a configuration.  A child is popped from the queue
        #: when it starts to render a config, then it's pushed back on
        #: when it's done.  This lets us use a blocking call to
        #: :func:`Queue.Queue.get` when waiting for an available
        #: child.
        self.available_children = \
            Queue(maxsize=Bcfg2.Options.setup.core_children)

        #: The flag that indicates when to stop child threads and
        #: processes
        self.terminate = DualEvent(threading_event=self.terminate)

        #: A :class:`Bcfg2.Server.MultiprocessingCore.RPCQueue` object
        #: used to send or publish commands to children.
        self.rpc_q = RPCQueue()

        #: A list of children that will be cycled through
        self._all_children = []

        #: An iterator that each child will be taken from in sequence,
        #: to provide a round-robin distribution of render requests
        self.children = None
예제 #2
0
    def __init__(self, setup):
        BuiltinCore.__init__(self, setup)
        if setup['children'] is None:
            setup['children'] = multiprocessing.cpu_count()

        #: A dict of child name -> one end of the
        #: :class:`multiprocessing.Pipe` object used to communicate
        #: with that child.  (The child is given the other end of the
        #: Pipe.)
        self.pipes = dict()

        #: A queue that keeps track of which children are available to
        #: render a configuration.  A child is popped from the queue
        #: when it starts to render a config, then it's pushed back on
        #: when it's done.  This lets us use a blocking call to
        #: :func:`Queue.Queue.get` when waiting for an available
        #: child.
        self.available_children = Queue(maxsize=self.setup['children'])

        # sigh.  multiprocessing was added in py2.6, which is when the
        # camelCase methods for threading objects were deprecated in
        # favor of the Pythonic under_score methods.  So
        # multiprocessing.Event *only* has is_set(), while
        # threading.Event has *both* isSet() and is_set().  In order
        # to make the core work with Python 2.4+, and with both
        # multiprocessing and threading Event objects, we just
        # monkeypatch self.terminate to have isSet().
        self.terminate = DualEvent(threading_event=self.terminate)
예제 #3
0
 def __init__(self, setup):
     TransportBase.__init__(self, setup)
     threading.Thread.__init__(self)
     self.save_file = os.path.join(self.data, ".saved")
     self.storage = load_storage_from_config(setup)
     self.queue = Queue(100000)
     self.terminate = threading.Event()
     self.start()
예제 #4
0
파일: interfaces.py 프로젝트: rcuza/bcfg2
 def __init__(self, core, datastore):
     Statistics.__init__(self, core, datastore)
     Threaded.__init__(self)
     threading.Thread.__init__(self)
     # Event from the core signaling an exit
     self.terminate = core.terminate
     self.work_queue = Queue(100000)
     self.pending_file = os.path.join(datastore, "etc",
                                      "%s.pending" % self.name)
     self.daemon = False
예제 #5
0
    def __init__(self, setup):
        TransportBase.__init__(self, setup)
        threading.Thread.__init__(self)
        self.save_file = os.path.join(self.data, ".saved")

        self.storage = load_storage_from_config(setup)
        self.storage.validate()

        self.queue = Queue(100000)
        self.terminate = threading.Event()
        self.debug_log("Reporting: Starting %s thread" %
                       self.__class__.__name__)
        self.start()
예제 #6
0
    def __init__(self):
        TransportBase.__init__(self)
        threading.Thread.__init__(self)
        self.save_file = os.path.join(self.data, ".saved")

        self.storage = Bcfg2.Options.setup.reporting_storage()
        self.storage.validate()

        self.queue = Queue(100000)
        self.terminate = threading.Event()
        self.debug_log("Reporting: Starting %s thread" %
                       self.__class__.__name__)
        self.start()
예제 #7
0
 def __init__(self, core, datastore):
     Bcfg2.Server.Plugin.Statistics.__init__(self, core, datastore)
     self.session = Bcfg2.Server.Snapshots.setup_session(core.cfile)
     self.work_queue = Queue()
     self.loader = threading.Thread(target=self.load_snapshot)
     self.loader.start()