def queue_rpc(self, rpc, callback=None, *args, **kwds):
if rpc is None:<EOL><INDENT>return<EOL><DEDENT>if rpc.state not in (_RUNNING, _FINISHING):<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>if isinstance(rpc, datastore_rpc.MultiRpc):<EOL><INDENT>rpcs = rpc.rpcs<EOL>if len(rpcs) > <NUM_LIT:1>:<EOL><INDENT>rpc.__done = False<EOL>def help_multi_rpc_along(r=rpc, c=callback, a=args, k=kwds):<EOL><INDENT>if r.state == _FINISHING and not r.__done:<EOL><INDENT>r.__done = True<EOL>c(*a, **k)<EOL><DEDENT><DEDENT>callback = help_multi_rpc_along<EOL>args = ()<EOL>kwds = {}<EOL><DEDENT><DEDENT>else:<EOL><INDENT>rpcs = [rpc]<EOL><DEDENT>for rpc in rpcs:<EOL><INDENT>self.rpcs[rpc] = (callback, args, kwds)<EOL><DEDENT>
Schedule an RPC with an optional callback.

        The caller must have previously sent the call to the service.
        The optional callback is called with the remaining arguments.

        NOTE: If the rpc is a MultiRpc, the callback will be called once
        for each sub-RPC.  TODO: Is this a good idea?