thirdparty/google_appengine/google/appengine/api/apiproxy_rpc.py
changeset 1278 a7766286a7be
parent 828 f5fd65cc3bf3
child 2309 be1b94099f2d
equal deleted inserted replaced
1277:5c931bd3dc1e 1278:a7766286a7be
    35   IDLE = 0
    35   IDLE = 0
    36   RUNNING = 1
    36   RUNNING = 1
    37   FINISHING = 2
    37   FINISHING = 2
    38 
    38 
    39   def __init__(self, package=None, call=None, request=None, response=None,
    39   def __init__(self, package=None, call=None, request=None, response=None,
    40                callback=None, stub=None):
    40                callback=None, deadline=None, stub=None):
    41     """Constructor for the RPC object.
    41     """Constructor for the RPC object.
    42 
    42 
    43     All arguments are optional, and simply set members on the class.
    43     All arguments are optional, and simply set members on the class.
    44     These data members will be overriden by values passed to MakeCall.
    44     These data members will be overriden by values passed to MakeCall.
    45 
    45 
    47       package: string, the package for the call
    47       package: string, the package for the call
    48       call: string, the call within the package
    48       call: string, the call within the package
    49       request: ProtocolMessage instance, appropriate for the arguments
    49       request: ProtocolMessage instance, appropriate for the arguments
    50       response: ProtocolMessage instance, appropriate for the response
    50       response: ProtocolMessage instance, appropriate for the response
    51       callback: callable, called when call is complete
    51       callback: callable, called when call is complete
       
    52       deadline: A double specifying the deadline for this call as the number of
       
    53                 seconds from the current time. Ignored if non-positive.
    52       stub: APIProxyStub instance, used in default _WaitImpl to do real call
    54       stub: APIProxyStub instance, used in default _WaitImpl to do real call
    53     """
    55     """
    54     self.__exception = None
    56     self.__exception = None
    55     self.__state = RPC.IDLE
    57     self.__state = RPC.IDLE
    56     self.__traceback = None
    58     self.__traceback = None
    58     self.package = package
    60     self.package = package
    59     self.call = call
    61     self.call = call
    60     self.request = request
    62     self.request = request
    61     self.response = response
    63     self.response = response
    62     self.callback = callback
    64     self.callback = callback
       
    65     self.deadline = deadline
    63     self.stub = stub
    66     self.stub = stub
    64 
    67 
    65   def MakeCall(self, package=None, call=None, request=None, response=None,
    68   def MakeCall(self, package=None, call=None, request=None, response=None,
    66                callback=None):
    69                callback=None, deadline=None):
    67     """Makes an asynchronous (i.e. non-blocking) API call within the
    70     """Makes an asynchronous (i.e. non-blocking) API call within the
    68     specified package for the specified call method.
    71     specified package for the specified call method.
    69 
    72 
    70     It will call the _MakeRealCall to do the real job.
    73     It will call the _MakeRealCall to do the real job.
    71 
    74 
    79     self.callback = callback or self.callback
    82     self.callback = callback or self.callback
    80     self.package = package or self.package
    83     self.package = package or self.package
    81     self.call = call or self.call
    84     self.call = call or self.call
    82     self.request = request or self.request
    85     self.request = request or self.request
    83     self.response = response or self.response
    86     self.response = response or self.response
       
    87     self.deadline = deadline or self.deadline
    84 
    88 
    85     assert self.__state is RPC.IDLE, ('RPC for %s.%s has already been started' %
    89     assert self.__state is RPC.IDLE, ('RPC for %s.%s has already been started' %
    86                                       (self.package, self.call))
    90                                       (self.package, self.call))
    87     assert self.callback is None or callable(self.callback)
    91     assert self.callback is None or callable(self.callback)
    88 
    92