python类Condition()的实例源码

bulkio_data_helpers.py 文件源码 项目:core-framework 作者: RedhawkSDR 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, porttype):
        """
        Instantiates a new object responsible for writing data from the port
        into an array.

        It is important to notice that the porttype is a BULKIO__POA type and
        not a BULKIO type.  The reason is because it is used to generate a
        Port class that will be returned when the getPort() is invoked.  The
        returned class is the one acting as a server and therefore must be a
        Portable Object Adapter rather and a simple BULKIO object.

        Inputs:
            <porttype>        The BULKIO__POA data type
        """
        StreamMgr.__init__(self)
        self.port_type = porttype
        self.sri=bulkio_helpers.defaultSRI
        self.data = []
        self.timestamps = []
        self.gotEOS = False
        self.breakBlock = False
        self.port_lock = threading.Lock()
        self.port_cond = threading.Condition(self.port_lock)
__init__.py 文件源码 项目:core-framework 作者: RedhawkSDR 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, thread_sleep=0.1, parent=None, storeMessages = False):
        self.consumer_lock = threading.Lock()
        threading.Thread.__init__(self)
        self._terminateMe=False
        self._pauseMe=True
        self.state = threading.Condition()
        self.setDaemon(True)
        self.actionQueue = Queue.Queue()
        self.thread_sleep = thread_sleep
        self._messages = {}
        self._allMsg = []
        self._connections = {}
        self.consumers = {}
        self.supplier_admin = self.SupplierAdmin_i(self)
        self._parent_comp = parent
        self._storeMessages = storeMessages
        self._storedMessages = []
        self.startPort()
Queue.py 文件源码 项目:kinect-2-libras 作者: inessadl 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self, maxsize=0):
        self.maxsize = maxsize
        self._init(maxsize)
        # mutex must be held whenever the queue is mutating.  All methods
        # that acquire mutex must release it before returning.  mutex
        # is shared between the three conditions, so acquiring and
        # releasing the conditions also acquires and releases mutex.
        self.mutex = _threading.Lock()
        # Notify not_empty whenever an item is added to the queue; a
        # thread waiting to get is notified then.
        self.not_empty = _threading.Condition(self.mutex)
        # Notify not_full whenever an item is removed from the queue;
        # a thread waiting to put is notified then.
        self.not_full = _threading.Condition(self.mutex)
        # Notify all_tasks_done whenever the number of unfinished tasks
        # drops to zero; thread waiting to join() is notified to resume
        self.all_tasks_done = _threading.Condition(self.mutex)
        self.unfinished_tasks = 0
settings.py 文件源码 项目:mongodb-monitoring 作者: jruaux 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self,
                 seeds=None,
                 replica_set_name=None,
                 pool_class=None,
                 pool_options=None,
                 monitor_class=None,
                 condition_class=None,
                 local_threshold_ms=LOCAL_THRESHOLD_MS,
                 server_selection_timeout=SERVER_SELECTION_TIMEOUT):
        """Represent MongoClient's configuration.

        Take a list of (host, port) pairs and optional replica set name.
        """
        self._seeds = seeds or [('localhost', 27017)]
        self._replica_set_name = replica_set_name
        self._pool_class = pool_class or pool.Pool
        self._pool_options = pool_options or PoolOptions()
        self._monitor_class = monitor_class or monitor.Monitor
        self._condition_class = condition_class or threading.Condition
        self._local_threshold_ms = local_threshold_ms
        self._server_selection_timeout = server_selection_timeout
        self._direct = (len(self._seeds) == 1 and not replica_set_name)
pool.py 文件源码 项目:deb-python-cassandra-driver 作者: openstack 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self, host, host_distance, session):
        self.host = host
        self.host_distance = host_distance
        self._session = weakref.proxy(session)
        self._lock = Lock()
        # this is used in conjunction with the connection streams. Not using the connection lock because the connection can be replaced in the lifetime of the pool.
        self._stream_available_condition = Condition(self._lock)
        self._is_replacing = False

        if host_distance == HostDistance.IGNORED:
            log.debug("Not opening connection to ignored host %s", self.host)
            return
        elif host_distance == HostDistance.REMOTE and not session.cluster.connect_to_remote_hosts:
            log.debug("Not opening connection to remote host %s", self.host)
            return

        log.debug("Initializing connection for host %s", self.host)
        self._connection = session.cluster.connection_factory(host.address)
        self._keyspace = session.keyspace
        if self._keyspace:
            self._connection.set_keyspace_blocking(self._keyspace)
        log.debug("Finished initializing connection for host %s", self.host)
pool.py 文件源码 项目:deb-python-cassandra-driver 作者: openstack 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, host, host_distance, session):
        self.host = host
        self.host_distance = host_distance

        self._session = weakref.proxy(session)
        self._lock = RLock()
        self._conn_available_condition = Condition()

        log.debug("Initializing new connection pool for host %s", self.host)
        core_conns = session.cluster.get_core_connections_per_host(host_distance)
        self._connections = [session.cluster.connection_factory(host.address)
                             for i in range(core_conns)]

        self._keyspace = session.keyspace
        if self._keyspace:
            for conn in self._connections:
                conn.set_keyspace_blocking(self._keyspace)

        self._trash = set()
        self._next_trash_allowed_at = time.time()
        self.open_count = core_conns
        log.debug("Finished initializing new connection pool for host %s", self.host)
pool.py 文件源码 项目:deb-python-cassandra-driver 作者: openstack 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def _wait_for_conn(self, timeout):
        start = time.time()
        remaining = timeout

        while remaining > 0:
            # wait on our condition for the possibility that a connection
            # is useable
            self._await_available_conn(remaining)

            # self.shutdown() may trigger the above Condition
            if self.is_shutdown:
                raise ConnectionException("Pool is shutdown")

            conns = self._connections
            if conns:
                least_busy = min(conns, key=lambda c: c.in_flight)
                with least_busy.lock:
                    if least_busy.in_flight < least_busy.max_request_id:
                        least_busy.in_flight += 1
                        return least_busy, least_busy.get_request_id()

            remaining = timeout - (time.time() - start)

        raise NoConnectionsAvailable()
Py25Queue.py 文件源码 项目:Projects 作者: it2school 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self, maxsize=0):
        try:
            import threading
        except ImportError:
            import dummy_threading as threading
        self._init(maxsize)
        # mutex must be held whenever the queue is mutating.  All methods
        # that acquire mutex must release it before returning.  mutex
        # is shared between the three conditions, so acquiring and
        # releasing the conditions also acquires and releases mutex.
        self.mutex = threading.Lock()
        # Notify not_empty whenever an item is added to the queue; a
        # thread waiting to get is notified then.
        self.not_empty = threading.Condition(self.mutex)
        # Notify not_full whenever an item is removed from the queue;
        # a thread waiting to put is notified then.
        self.not_full = threading.Condition(self.mutex)
        # Notify all_tasks_done whenever the number of unfinished tasks
        # drops to zero; thread waiting to join() is notified to resume
        self.all_tasks_done = threading.Condition(self.mutex)
        self.unfinished_tasks = 0
Queue.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def __init__(self, maxsize=0):
        self.maxsize = maxsize
        self._init(maxsize)
        # mutex must be held whenever the queue is mutating.  All methods
        # that acquire mutex must release it before returning.  mutex
        # is shared between the three conditions, so acquiring and
        # releasing the conditions also acquires and releases mutex.
        self.mutex = _threading.Lock()
        # Notify not_empty whenever an item is added to the queue; a
        # thread waiting to get is notified then.
        self.not_empty = _threading.Condition(self.mutex)
        # Notify not_full whenever an item is removed from the queue;
        # a thread waiting to put is notified then.
        self.not_full = _threading.Condition(self.mutex)
        # Notify all_tasks_done whenever the number of unfinished tasks
        # drops to zero; thread waiting to join() is notified to resume
        self.all_tasks_done = _threading.Condition(self.mutex)
        self.unfinished_tasks = 0
protocol_ascii.py 文件源码 项目:pyuf 作者: uArm-Developer 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, ufc, node, iomap, cmd_pend_size = 2, timeout = 1):

        self.ports = {
            'cmd_async': {'dir': 'in', 'type': 'topic', 'callback': self.cmd_async_cb},
            'cmd_sync': {'dir': 'in', 'type': 'service', 'callback': self.cmd_sync_cb},

            'report': {'dir': 'out', 'type': 'topic'},
            'status': {'dir': 'out', 'type': 'topic'}, # report lost, etc...

            'service': {'dir': 'in', 'type': 'service', 'callback': self.service_cb},

            'packet_in': {'dir': 'in', 'type': 'topic', 'callback': self.packet_in_cb},
            'packet_out': {'dir': 'out', 'type': 'topic'},
        }

        self.node = node
        self.logger = logging.getLogger('uf.' + node.replace('/', '.'))
        self.cmd_pend = {}
        self.cmd_pend_size = cmd_pend_size
        self.cmd_pend_c = threading.Condition()
        self.timeout = timeout
        self.cnt_lock = _thread.allocate_lock()
        self.cnt = 1 # no reply if cnt == 0, FIXME
        ufc.node_init(node, self.ports, iomap)
fyserial.py 文件源码 项目:fygimbal 作者: scanlime 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, port='/dev/ttyAMA0', baudrate=115200, verbose=True, connected=None):
        self.verbose = verbose
        self.version = None

        self.connectedCV = threading.Condition()
        self.responseQueue = queue.Queue()
        self.port = serial.Serial(port, baudrate=baudrate)
        self._transactionLock = threading.Lock()

        self.tx = self.transmitThreadClass(self.port, verbose=self.verbose)
        self.rx = self.receiverThreadClass(self.port, callback=self._receive, verbose=self.verbose)
        self.rx.start()
        self.tx.start()

        if connected is None:
            self.connected = True
            self.connected = self._testForExistingConnection()
        else:
            self.connected = connected
        if self.verbose:
            if self.connected:
                print("Already connected to gimbal, version %s" % self.version)
            else:
                print("Waiting for gimbal to power on")
mturk_manager.py 文件源码 项目:ParlAI 作者: facebookresearch 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, opt, mturk_agent_ids, is_test=False):
        """Create an MTurkManager using the given setup opts and a list of
        agent_ids that will participate in each conversation
        """
        self.opt = opt
        self.server_url = None
        self.topic_arn = None
        self.port = 443
        self.task_group_id = None
        self.run_id = None
        self.mturk_agent_ids = mturk_agent_ids
        self.task_files_to_copy = None
        self.is_sandbox = opt['is_sandbox']
        self.worker_pool_change_condition = threading.Condition()
        self.onboard_function = None
        self.num_conversations = opt['num_conversations']
        self.required_hits = math.ceil(
            self.num_conversations * len(self.mturk_agent_ids) * HIT_MULT
        )
        self.socket_manager = None
        self.is_test = is_test
        self._init_logs()

    # Helpers and internal manager methods #
pubSub.py 文件源码 项目:Learning-Concurrency-in-Python 作者: PacktPublishing 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def main():
  integers = []
  condition = threading.Condition()

  # Our Publisher
  pub1 = Publisher(integers, condition)
  pub1.start()

  # Our Subscribers
  sub1 = Subscriber(integers, condition)
  sub2 = Subscriber(integers, condition)
  sub1.start()
  sub2.start()

  ## Joining our Threads
  pub1.join()
  consumer1.join()
  consumer2.join()
client.py 文件源码 项目:fastatsd 作者: qntln 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, host: str = 'localhost', port: int = 8125, prefix: str = '', maxudpsize: Any = _sentinel) -> None:
        '''
        Create a new client.

        :param host: Host of the statsd server.
        :param port: Port of the statsd server, 8125 by default.
        :param prefix: String that will be prefixed to any stat description.
        :param maxudpsize: Ignored in this implementation.
        '''
        self._prefix = prefix + '.' if prefix else ''
        self._server_addr = (socket.gethostbyname(host), port)
        self._queue = cystatsd.MetricCollector()
        self._queue_cv = threading.Condition()
        if maxudpsize is not self._sentinel:
            warnings.warn('Fastatsd client doesn\'t support maxudpsize')
        self._start_sender_thread()
Queue.py 文件源码 项目:ghostlines-robofont 作者: ghostlines 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, maxsize=0):
        self.maxsize = maxsize
        self._init(maxsize)
        # mutex must be held whenever the queue is mutating.  All methods
        # that acquire mutex must release it before returning.  mutex
        # is shared between the three conditions, so acquiring and
        # releasing the conditions also acquires and releases mutex.
        self.mutex = _threading.Lock()
        # Notify not_empty whenever an item is added to the queue; a
        # thread waiting to get is notified then.
        self.not_empty = _threading.Condition(self.mutex)
        # Notify not_full whenever an item is removed from the queue;
        # a thread waiting to put is notified then.
        self.not_full = _threading.Condition(self.mutex)
        # Notify all_tasks_done whenever the number of unfinished tasks
        # drops to zero; thread waiting to join() is notified to resume
        self.all_tasks_done = _threading.Condition(self.mutex)
        self.unfinished_tasks = 0
Queue.py 文件源码 项目:ghostlines-robofont 作者: ghostlines 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, maxsize=0):
        self.maxsize = maxsize
        self._init(maxsize)
        # mutex must be held whenever the queue is mutating.  All methods
        # that acquire mutex must release it before returning.  mutex
        # is shared between the three conditions, so acquiring and
        # releasing the conditions also acquires and releases mutex.
        self.mutex = _threading.Lock()
        # Notify not_empty whenever an item is added to the queue; a
        # thread waiting to get is notified then.
        self.not_empty = _threading.Condition(self.mutex)
        # Notify not_full whenever an item is removed from the queue;
        # a thread waiting to put is notified then.
        self.not_full = _threading.Condition(self.mutex)
        # Notify all_tasks_done whenever the number of unfinished tasks
        # drops to zero; thread waiting to join() is notified to resume
        self.all_tasks_done = _threading.Condition(self.mutex)
        self.unfinished_tasks = 0
asynconnect.py 文件源码 项目:aquests 作者: hansroh 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def __init__ (self, address, lock = None, logger = None):
        self.address = address
        self.lock = lock
        self.logger = logger
        self._cv = threading.Condition ()       
        self.__sendlock = None
        self.__no_more_request = False
        self.set_event_time ()
        self.handler = None

        self.auth = None
        self.proxy = False
        self.initialize_connection ()
        self._closed = False
        self.backend = False

        self.ac_in_buffer = b''
        self.incoming = []
        self.producer_fifo = self.fifo_class ()
        asyncore.dispatcher.__init__(self)
midi_hub.py 文件源码 项目:magenta 作者: tensorflow 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, outport, sequence, start_time=time.time(),
               allow_updates=False, channel=0, offset=0.0):
    self._outport = outport
    self._channel = channel
    self._offset = offset

    # Set of notes (pitches) that are currently on.
    self._open_notes = set()
    # Lock for serialization.
    self._lock = threading.RLock()
    # A control variable to signal when the sequence has been updated.
    self._update_cv = threading.Condition(self._lock)
    # The queue of mido.Message objects to send, sorted by ascending time.
    self._message_queue = deque()
    # An event that is set when `stop` has been called.
    self._stop_signal = threading.Event()

    # Initialize message queue.
    # We first have to allow "updates" to set the initial sequence.
    self._allow_updates = True
    self.update_sequence(sequence, start_time=start_time)
    # We now make whether we allow updates dependent on the argument.
    self._allow_updates = allow_updates

    super(MidiPlayer, self).__init__()
_notification.py 文件源码 项目:python-zhmcclient 作者: zhmcclient 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, handover_dict, handover_cond):
        """
        Parameters:

          handover_dict (dict): Dictionary for handing over the notification
            header and message from this listener thread to the receiver
            thread. Must initially be an empty dictionary.

          handover_cond (threading.Condition): Condition object for handing
            over the notification from this listener thread to the receiver
            thread. Must initially be a new threading.Condition object.
        """

        # Sync variables for thread-safe handover between listener thread and
        # receiver thread:
        self._handover_dict = handover_dict  # keys: headers, message
        self._handover_cond = handover_cond

        # Wait timeout to honor keyboard interrupts after this time:
        self._wait_timeout = 10.0  # seconds
Queue.py 文件源码 项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, maxsize=0):
        self.maxsize = maxsize
        self._init(maxsize)
        # mutex must be held whenever the queue is mutating.  All methods
        # that acquire mutex must release it before returning.  mutex
        # is shared between the three conditions, so acquiring and
        # releasing the conditions also acquires and releases mutex.
        self.mutex = _threading.Lock()
        # Notify not_empty whenever an item is added to the queue; a
        # thread waiting to get is notified then.
        self.not_empty = _threading.Condition(self.mutex)
        # Notify not_full whenever an item is removed from the queue;
        # a thread waiting to put is notified then.
        self.not_full = _threading.Condition(self.mutex)
        # Notify all_tasks_done whenever the number of unfinished tasks
        # drops to zero; thread waiting to join() is notified to resume
        self.all_tasks_done = _threading.Condition(self.mutex)
        self.unfinished_tasks = 0
gae_handler.py 文件源码 项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, method, url, headers, body, response, wfile):
        self.method = method
        self.wfile = wfile
        self.url = url
        self.headers = headers
        self.body = body
        self.response = response

        self.keep_running = True
        self.blocked = False

        self.lock = threading.Lock()
        self.waiter = threading.Condition(self.lock)

        self.data_list = {}
        # begin => payload
        self.data_size = 0

        self.req_begin = 0
        self.req_end = 0
        self.wait_begin = 0
Queue.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, maxsize=0):
        self.maxsize = maxsize
        self._init(maxsize)
        # mutex must be held whenever the queue is mutating.  All methods
        # that acquire mutex must release it before returning.  mutex
        # is shared between the three conditions, so acquiring and
        # releasing the conditions also acquires and releases mutex.
        self.mutex = _threading.Lock()
        # Notify not_empty whenever an item is added to the queue; a
        # thread waiting to get is notified then.
        self.not_empty = _threading.Condition(self.mutex)
        # Notify not_full whenever an item is removed from the queue;
        # a thread waiting to put is notified then.
        self.not_full = _threading.Condition(self.mutex)
        # Notify all_tasks_done whenever the number of unfinished tasks
        # drops to zero; thread waiting to join() is notified to resume
        self.all_tasks_done = _threading.Condition(self.mutex)
        self.unfinished_tasks = 0
gae_handler.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, method, url, headers, body, response, wfile):
        self.method = method
        self.wfile = wfile
        self.url = url
        self.headers = headers
        self.body = body
        self.response = response

        self.keep_running = True
        self.blocked = False

        self.lock = threading.Lock()
        self.waiter = threading.Condition(self.lock)

        self.data_list = {}
        # begin => payload
        self.data_size = 0

        self.req_begin = 0
        self.req_end = 0
        self.wait_begin = 0
requeue.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self,
               queue_capacity,
               requeue_capacity=None,
               queue_factory=Queue.Queue,
               get_time=time.time):
    """Initialize a ReQueue instance.

    Args:
      queue_capacity: The number of items that can be put in the ReQueue.
      requeue_capacity: The numer of items that can be reput in the ReQueue.
      queue_factory: Used for dependency injection.
      get_time: Used for dependency injection.
    """
    if requeue_capacity is None:
      requeue_capacity = queue_capacity

    self.get_time = get_time
    self.queue = queue_factory(queue_capacity)
    self.requeue = queue_factory(requeue_capacity)
    self.lock = threading.Lock()
    self.put_cond = threading.Condition(self.lock)
    self.get_cond = threading.Condition(self.lock)
tornado_fetcher.py 文件源码 项目:Url 作者: beiruan 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def sync_fetch(self, task):
        '''Synchronization fetch, usually used in xmlrpc thread'''
        if not self._running:
            return self.ioloop.run_sync(functools.partial(self.async_fetch, task, lambda t, _, r: True))

        wait_result = threading.Condition()
        _result = {}

        def callback(type, task, result):
            wait_result.acquire()
            _result['type'] = type
            _result['task'] = task
            _result['result'] = result
            wait_result.notify()
            wait_result.release()

        wait_result.acquire()
        self.ioloop.add_callback(self.fetch, task, callback)
        while 'result' not in _result:
            wait_result.wait()
        wait_result.release()
        return _result['result']
test_election.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def setUp(self):
        super(KazooElectionTests, self).setUp()
        self.path = "/" + uuid.uuid4().hex

        self.condition = threading.Condition()

        # election contenders set these when elected. The exit event is set by
        # the test to make the leader exit.
        self.leader_id = None
        self.exit_event = None

        # tests set this before the event to make the leader raise an error
        self.raise_exception = False

        # set by a worker thread when an unexpected error is hit.
        # better way to do this?
        self.thread_exc_info = None
sampler.py 文件源码 项目:aupyom 作者: pierre-rouanet 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self, sr=22050, backend='sounddevice'):
        """
        :param int sr: samplerate used - all sounds added to the sampler will automatically be resampled if needed (- his can be a CPU consumming task, try to use sound with all identical sampling rate if possible.
        :param str backend: backend used for playing sound. Can be either 'sounddevice' or 'dummy'.

        """
        self.sr = sr
        self.sounds = []

        self.chunks = Queue(1)
        self.chunk_available = Condition()

        if backend == 'dummy':
            from .dummy_stream import DummyStream
            self.BackendStream = DummyStream
        elif backend == 'sounddevice':
            from sounddevice import OutputStream
            self.BackendStream = OutputStream
        else:
            raise ValueError("Backend can either be 'sounddevice' or 'dummy'")

        # TODO: use a process instead?
        self.play_thread = Thread(target=self.run)
        self.play_thread.daemon = True
        self.play_thread.start()
queue.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self, maxsize=0):
        self.maxsize = maxsize
        self._init(maxsize)
        # mutex must be held whenever the queue is mutating.  All methods
        # that acquire mutex must release it before returning.  mutex
        # is shared between the three conditions, so acquiring and
        # releasing the conditions also acquires and releases mutex.
        self.mutex = _threading.Lock()
        # Notify not_empty whenever an item is added to the queue; a
        # thread waiting to get is notified then.
        self.not_empty = _threading.Condition(self.mutex)
        # Notify not_full whenever an item is removed from the queue;
        # a thread waiting to put is notified then.
        self.not_full = _threading.Condition(self.mutex)
        # Notify all_tasks_done whenever the number of unfinished tasks
        # drops to zero; thread waiting to join() is notified to resume
        self.all_tasks_done = _threading.Condition(self.mutex)
        self.unfinished_tasks = 0
client.py 文件源码 项目:caproto 作者: NSLS-II 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, *, log_level='ERROR'):
        self.log_level = log_level
        self.udp_sock = None
        self._search_lock = threading.RLock()

        self.search_results = {}  # map name to (time, address)
        self.unanswered_searches = {}  # map search id (cid) to name

        self.listeners = weakref.WeakSet()

        self.broadcaster = ca.Broadcaster(our_role=ca.CLIENT)
        self.broadcaster.log.setLevel(self.log_level)
        self.command_bundle_queue = queue.Queue()
        self.command_cond = threading.Condition()

        self.selector = SelectorThread()
        self.command_thread = threading.Thread(target=self.command_loop,
                                               daemon=True)
        self.command_thread.start()
marathon-bigip-ctlr.py 文件源码 项目:marathon-bigip-ctlr 作者: F5Networks 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, marathon, verify_interval, cccls):
        """Class init.

        Starts a thread that waits for Marathon events,
        then configures BIG-IP based on the Marathon state
        """
        self.__marathon = marathon
        # appId -> MarathonApp
        self.__apps = dict()
        self.__cccls = cccls
        self.__verify_interval = verify_interval

        self.__condition = threading.Condition()
        self.__thread = threading.Thread(target=self.do_reset)
        self.__pending_reset = False
        self.__thread.daemon = True
        self.__thread.start()
        self.__timer = None
        self._backoff_timer = 1
        self._max_backoff_time = 128

        # Fetch the base data
        self.reset_from_tasks()


问题


面经


文章

微信
公众号

扫码关注公众号