threaded_item.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:Parlay 作者: PromenadeSoftware 项目源码 文件源码
def get_item_by_id(self, item_id):
        """
        Returns a handler object that can be used to send messages to an item.

        :param item_id: globally unique id of the item
        :return: a proxy object for the item
        """

        if not self._reactor.running:
            raise Exception("You must call parlay.utils.setup() at the beginning of a script!")

        def find():
            g = self._find_item_info(self.discovery, item_id, "ID")
            item_disc = next(g)
            return self._proxy_item(item_disc)

        try:
            defer.returnValue(find())
        except StopIteration:
            # discover and try again
            try:
                yield self.discover(force=False)
                defer.returnValue(find())
            except StopIteration:
                raise KeyError("Couldn't find item with id " + str(item_id))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号