~rvb/maas/transaction-1.7-bug-1409852

« back to all changes in this revision

Viewing changes to src/provisioningserver/rpc/common.py

merged upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
        return self._conn.ident
54
54
 
55
55
    @asynchronous
56
 
    def __call__(self, cmd, **kwargs):
 
56
    def __call__(self, cmd, *args, **kwargs):
57
57
        """Call a remote RPC method.
58
58
 
59
59
        This is how the client is normally used.
60
60
 
 
61
        :note:
 
62
            Though the call signature shows positional arguments, their use is
 
63
            an error. They're in the signature is so this method can detect
 
64
            them and provide a better error message than that from Python.
 
65
            Python's error message when arguments don't match the call's
 
66
            signature is not great at best, but it also makes it hard to
 
67
            figure out the receiver when the `TypeError` is raised in a
 
68
            different stack from the caller's, e.g. when calling into the
 
69
            Twisted reactor from a thread.
 
70
 
61
71
        :param cmd: The `amp.Command` child class representing the remote
62
72
            method to be invoked.
63
73
        :param kwargs: Any parameters to the remote method.  Only keyword
65
75
        :return: A deferred result.  Call its `wait` method (with a timeout
66
76
            in seconds) to block on the call's completion.
67
77
        """
 
78
        if len(args) != 0:
 
79
            receiver_name = "%s.%s" % (
 
80
                self.__module__, self.__class__.__name__)
 
81
            raise TypeError(
 
82
                "%s called with %d positional arguments, %r, but positional "
 
83
                "arguments are not supported. Usage: client(command, arg1="
 
84
                "value1, ...)" % (receiver_name, len(args), args))
 
85
 
68
86
        return self._conn.callRemote(cmd, **kwargs)
69
87
 
70
88
    @asynchronous