netpycos.py 文件源码

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

项目:pycos 作者: pgiri 项目源码 文件源码
def locate(name, location=None, timeout=None):
        """Must be used with 'yield' as 'rti = yield RTI.locate("name")'.

        Returns RTI instance to registered RTI at a remote peer so its method
        can be used to execute tasks at that peer.

        If 'location' is given, RTI is looked up at that specific peer;
        otherwise, all known peers are queried for given name.
        """
        if not RTI._pycos:
            RTI._pycos = Pycos.instance()
        req = _NetRequest('locate_rti', kwargs={'name': name}, dst=location, timeout=timeout)
        req.event = Event()
        req_id = id(req)
        RTI._pycos._lock.acquire()
        RTI._pycos._pending_reqs[req_id] = req
        RTI._pycos._lock.release()
        _Peer.send_req_to(req, location)
        if (yield req.event.wait(timeout)) is False:
            req.reply = None
        rti = req.reply
        RTI._pycos._lock.acquire()
        RTI._pycos._pending_reqs.pop(req_id, None)
        RTI._pycos._lock.release()
        raise StopIteration(rti)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号