示例#1
0
def rpc2(path, args=None, kwargs=None, tega_id=None):
    '''
    This method is called by server.py
    '''
    try:
        return rpc(path, args, kwargs)
    except NonLocalRPC:
        if tega_id:
            subscriber = get_subscriber_for_local_db(path)
            try:
                result = yield request(subscriber,
                                       REQUEST_TYPE.RPC,
                                       tega_id=tega_id,
                                       path=path,
                                       args=args,
                                       kwargs=kwargs)
                return result
            except gen.TimeoutError:
                raise
        else:
            raise ValueError('tega_id required for this method')
    except KeyError:
        subscriber = get_subscriber_for_global_db()
        try:
            result = yield request(subscriber,
                                   REQUEST_TYPE.RPC,
                                   tega_id=subscriber.tega_id,
                                   path=path,
                                   args=args,
                                   kwargs=kwargs)
            return result
        except gen.TimeoutError:
            raise
示例#2
0
文件: idb.py 项目: araobp/tega
def rpc2(path, args=None, kwargs=None, tega_id=None):
    '''
    This method is called by server.py
    '''
    try:
        return rpc(path, args, kwargs)
    except NonLocalRPC:
        if tega_id:
            subscriber = get_subscriber_for_local_db(path)
            try:
                result = yield request(subscriber,
                                       REQUEST_TYPE.RPC,
                                       tega_id=tega_id,
                                       path=path,
                                       args=args,
                                       kwargs=kwargs)
                return result
            except gen.TimeoutError:
                raise
        else:
            raise ValueError('tega_id required for this method')
    except KeyError:
        subscriber = get_subscriber_for_global_db()
        try:
            result = yield request(subscriber,
                                   REQUEST_TYPE.RPC,
                                   tega_id=subscriber.tega_id,
                                   path=path,
                                   args=args,
                                   kwargs=kwargs)
            return result
        except gen.TimeoutError:
            raise
示例#3
0
文件: server.py 项目: lisidan/tega
def ask_global_db(root_oids, subscriber):
    logging.debug('ask global db -- {}'.format(root_oids))
    try:
        result = yield request(subscriber,
                               REQUEST_TYPE.REFER,
                               tega_id=None,
                               path=None,
                               args=root_oids,
                               kwargs=None)
        return result
    except gen.TimeoutError:
        raise
示例#4
0
文件: server.py 项目: lisidan/tega
def sync_check(root_oids, subscriber):
    kwargs = {}
    for root_oid in root_oids:
        try:
            version = tega.idb.get_version(root_oid)
        except KeyError:
            version = -1
        kwargs[root_oid] = version
    logging.debug('sync check -- {}'.format(kwargs))
    try:
        result = yield request(subscriber,
                               REQUEST_TYPE.SYNC,
                               tega_id=None,
                               path=None,
                               args=None,
                               kwargs=kwargs)
        return result
    except gen.TimeoutError:
        raise