Open socketpair opened 10 years ago
That's probably because you're using the @defer.inlineCallbacks decorator on a non-generator function. I've been bitten by that myself and the error messaging stinks. Try adding "yield None" on the last line of the function.
On Thu, Nov 20, 2014 at 3:02 PM, Коренберг Марк notifications@github.com wrote:
This does not work (prints None) silently and does not even say that something wrong.
class MyObj(objects.DBusObject): ... @defer.inlineCallbacks def dbus_identTest(self, dbusCaller=None): print 'Caller:', dbusCaller
— Reply to this email directly or view it on GitHub https://github.com/cocagne/txdbus/issues/21.
No, this does not work even with yield None
.
I have checked in debugger: it uses inspect
module, and in this case, it unable to detect that I use dbusCaller
argument. I use:
Why? Because inspect
see decorated function (instead of real) which does not have dbusCaller
. To prove that, I have written decorator:
def asd(fun):
def x(self, dbusCaller=None, *args, **kwargs):
return fun(self, *args, dbusCaller=dbusCaller, **kwargs)
return x
and use it like this:
@asd
@defer.inlineCallbacks
def dbus_identTest(self, dbusCaller=None):
print 'uid:', (yield self.getConnection().getConnectionUnixUser(dbusCaller))
And this works!
I don't understand why such functions are marked in this odd way, and also requiring to use inspect module... Why not to implement Method('identTest', caller_argument='xxx')
? this also will not break old applications
Oh I see. It's probably because of the function decorator. The inspect module will be looking for a dbusCaller argument in the wrapper function, not the original method. That could probably be worked around, particularly for inlineCallbacks given how common it is.
On Fri, Nov 21, 2014 at 2:15 PM, Коренберг Марк notifications@github.com wrote:
I don't understand why such functions are marked in this way. Why not to implement Method('identTest', caller_argument='xxx') ? this also will not break old applications
— Reply to this email directly or view it on GitHub https://github.com/cocagne/txdbus/issues/21#issuecomment-64031099.
Did not understood:
That could probably be worked around, particularly for inlineCallbacks given how common it is.
Can you implement Method('identTest', caller_argument='xxx')
?
This does not work (prints None) silently and does not even say that something wrong.