[Twisted-Python] AMP Argument.toBox's proto argument is a locator, not the proto?

Laurens Van Houtven _ at lvh.io
Mon Sep 30 03:45:39 MDT 2013


Hi everyone,


I think I've hit one of those cases where AMP really seems to want
everything (locator, receiver, sender) to be an instance of t.p.amp.AMP :-(

I've written some code that tries to multiplex stream transports over AMP:

https://github.com/lvh/txampext/blob/multiplexing/txampext/multiplexing.py

The repo contains an example server and client, which demonstrate the issue:

https://github.com/lvh/txampext/blob/multiplexing/docs/examples/multiplexing_client.py
https://github.com/lvh/txampext/blob/multiplexing/docs/examples/multiplexing_server.py

In order to do some of this multiplexing, I need access to the protocol
instance inside the responder on the server side. Fortunately, I already
had some code that exposed box senders (after a lot of advice from Glyph).
I modified it to expose the protocol as well:

https://github.com/lvh/txampext/blob/multiplexing/txampext/exposed.py#L41

However, it turns out fromBox gets called with the *responder locator* as
the "proto" argument, not the actual protocol.

The server has a pudb call that makes it easy (?!) to trace this down. The
CommandLocator class, inside doit (a function defined in
_wrapWithSerialization) passes "self" to command.parseArguments:

https://twistedmatrix.com/trac/browser/trunk/twisted/protocols/amp.py#L1015

This is the part where I think the contract is broken, since parseArguments
claims to want the protocol (well, it says it wants the AMP protocol,
which, subclassing everything, is also all of the things, of course), but
receives the responder locator.

What am I doing wrong? Is this a bug?

confusedly,
lvh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20130930/027bb877/attachment.html>


More information about the Twisted-Python mailing list