示例#1
0
文件: fake_client.py 项目: jinty/Zake
 def _fire_watches(self, paths, event, watch_source):
     for path in reversed(sorted(paths)):
         with self._open_close_lock:
             if self._connected:
                 with self._watches_lock:
                     watches = list(watch_source.pop(path, []))
                 for w in watches:
                     cb = utils.make_cb(w, [event])
                     self.handler.dispatch_callback(cb)
示例#2
0
 def _fire_watches(self, paths, event, watch_source):
     for path in reversed(sorted(paths)):
         with self._open_close_lock:
             if self._connected:
                 with self._watches_lock:
                     watches = list(watch_source.pop(path, []))
                 for w in watches:
                     cb = utils.make_cb(w, [event])
                     self.handler.dispatch_callback(cb)
示例#3
0
文件: fake_client.py 项目: jinty/Zake
    def flush(self):
        self.verify()

        # This puts an item into the callback queue, and waits until it gets
        # called, this is a cheap way of knowing that the queue has been
        # cycled over (as this item goes in on the bottom) and only when the
        # items ahead of this callback are finished will this get called.
        wait_for = self.handler.event_object()
        fired = False

        def flip():
            wait_for.set()

        while not wait_for.is_set():
            if not fired:
                self.handler.dispatch_callback(utils.make_cb(flip))
                fired = True
            time.sleep(0.001)
示例#4
0
    def flush(self):
        self.verify()

        # This puts an item into the callback queue, and waits until it gets
        # called, this is a cheap way of knowing that the queue has been
        # cycled over (as this item goes in on the bottom) and only when the
        # items ahead of this callback are finished will this get called.
        wait_for = self.handler.event_object()
        fired = False

        def flip():
            wait_for.set()

        while not wait_for.is_set():
            if not fired:
                self.handler.dispatch_callback(utils.make_cb(flip))
                fired = True
            time.sleep(0.001)
示例#5
0
文件: fake_client.py 项目: jinty/Zake
 def _fire_state_change(self, state):
     with self._listeners_lock:
         listeners = list(self._listeners)
     for func in listeners:
         self.handler.dispatch_callback(utils.make_cb(func, [state]))
示例#6
0
 def _fire_state_change(self, state):
     with self._listeners_lock:
         listeners = list(self._listeners)
     for func in listeners:
         self.handler.dispatch_callback(utils.make_cb(func, [state]))