Missing attribute exception caused by SpecContainer missing 'bypyname'

Asked by bloated_zebra_head

I've been playing with txamqp, but am unable to run the txamqp_example.py script.
The exception is this:

  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/txamqp/protocol.py", line 107, in __init__
    self.FRAME_END = self.spec.constants.bypyname["frame_end"].id

exceptions.AttributeError: SpecContainer instance has no attribute 'bypyname'

I'm confused as to why this exception is even occuring, because if you look at the code for SpecContainer, you find this:

-----------------------------
class SpecContainer:

  def __init__(self):
    self.items = []
    self.byname = {}
    self.byid = {};
    self.indexes = {}
    self.bypyname = {}
------------------------------

But the exception indicates that python thinks bypyname isn't on the SpecContainer instance. Does anyone have a clue as to what I'm doing wrong?

I'm using Python 2.6 on Mac OSX.

Question information

Language:
English Edit question
Status:
Solved
For:
txAMQP Edit question
Assignee:
No assignee Edit question
Solved by:
bloated_zebra_head
Solved:
Last query:
Last reply:
Revision history for this message
Esteve Fernandez (esteve) said :
#1

That's rather strange. I don't have Python 2.6 at hand, but will download it and try running txAMQP. Just out of curiosity, what broker and spec file are you using?

Thanks for trying txAMQP!

Revision history for this message
bloated_zebra_head (sethcall) said :
#2

Hey,

It is strange. I did try 2.5 once as well...

I was using RabbitMQ and the 0.8 spec from
http://www.iona.com/opensource/amqp/amqp0-8.xml (not from Apache Qpid
project, since my understanding is that RabbitMQ can't interop with tha 0.8
spec)

Thanks for the help. I'm at a loss.

I forgot to mention. I also had another error before this. It had to do
with the FrameReceiver constructor.

Specifically, in protocol.py, this:

------------------------------
class AMQClient(FrameReceiver):

    channelClass = AMQChannel

    def __init__(self, delegate, vhost, *args, **kwargs):
        FrameReceiver.__init__(self, args, kwargs)
        self.delegate = delegate
------------------------------
threw an error at runtime--something to the effect that FrameReceiver did
not have a matching argument. I changed it instead to:

------------------------------
class AMQClient(FrameReceiver):

    channelClass = AMQChannel

    def __init__(self, delegate, vhost, *args, **kwargs):
        FrameReceiver.__init__(self, *delegate*)
        self.delegate = delegate
------------------------------

So anyway, that's also why I'm thinking I'm doing something just really
wrong, or I should be using an older version of python.

Which version of python have you used?

Seth

On Thu, Jan 15, 2009 at 5:02 AM, esteve <<email address hidden>
> wrote:

> Your question #57459 on txAMQP changed:
> https://answers.launchpad.net/txamqp/+question/57459
>
> Status: Open => Needs information
>
> esteve requested for more information:
> That's rather strange. I don't have Python 2.6 at hand, but will
> download it and try running txAMQP. Just out of curiosity, what broker
> and spec file are you using?
>
> Thanks for trying txAMQP!
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https://answers.launchpad.net/txamqp/+question/57459
>
> You received this question notification because you are a direct
> subscriber of the question.
>

Revision history for this message
Esteve Fernandez (esteve) said :
#3

The error you're seeing is due to the spec object not being passed to the parent class (FrameReceiver), so bypyname is empty. Could you change it back to the original version and tell me what error did you see?

How do you create instances of AMQClient?

One simple way to do it is to use the ClientCreator class (it's in twisted.internet.protocol.ClientCreator):

def gotClient(client):
    print "I'm connected to the broker: ", client
d = ClientCreator(reactor, AMQClient, delegate, vhost, spec).connectTCP(host, port)
d.addCallback(gotClient)

Revision history for this message
Esteve Fernandez (esteve) said :
#4

BTW, it's not that RabbitMQ can't interoperate with 0.8, but Qpid implements 0.8 along with some features of its own that makes it incompatible with some clients. RabbitMQ is pretty faithful to the standard, that's why you have to use the official spec file. You can find both Qpid and standard (RabbitMQ, OpenAMQ) spec files in the txAMQP distribution.

Revision history for this message
bloated_zebra_head (sethcall) said :
#5

File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/txamqp/protocol.py",
line 202, in __init__
    FrameReceiver.__init__(self, args, kwargs)
exceptions.TypeError: __init__() takes exactly 2 arguments (3 given)

I'm using your example to test this functionality (i already have
simpleserver.py running before I do this)
python txamqp_example.py localhost 8007 / guest guest path/to/amqp0-8.xml

On Thu, Jan 15, 2009 at 4:00 PM, esteve <<email address hidden>
> wrote:

> Your question #57459 on txAMQP changed:
> https://answers.launchpad.net/txamqp/+question/57459
>
> Status: Open => Needs information
>
> esteve requested for more information:
> The error you're seeing is due to the spec object not being passed to
> the parent class (FrameReceiver), so bypyname is empty. Could you change
> it back to the original version and tell me what error did you see?
>
> How do you create instances of AMQClient?
>
> One simple way to do it is to use the ClientCreator class (it's in
> twisted.internet.protocol.ClientCreator):
>
> def gotClient(client):
> print "I'm connected to the broker: ", client
> d = ClientCreator(reactor, AMQClient, delegate, vhost,
> spec).connectTCP(host, port)
> d.addCallback(gotClient)
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https://answers.launchpad.net/txamqp/+question/57459
>
> You received this question notification because you are a direct
> subscriber of the question.
>

Revision history for this message
Esteve Fernandez (esteve) said :
#6
Revision history for this message
Esteve Fernandez (esteve) said :
#7

Did you have the chance to test those two scripts? Let me know how it goes.

Revision history for this message
bloated_zebra_head (sethcall) said :
#8

I did, but I was having some sort of other problem that I'm certain is
of my own doing.

Sorry for the delay; I'm going to clean up my dev environment and try
again. I'll let you know how it goes ASAP.

On Sun, Jan 25, 2009 at 5:33 AM, esteve
<email address hidden> wrote:
> Your question #57459 on txAMQP changed:
> https://answers.launchpad.net/txamqp/+question/57459
>
> esteve requested for more information:
> Did you have the chance to test those two scripts? Let me know how it
> goes.
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https://answers.launchpad.net/txamqp/+question/57459
>
> You received this question notification because you are a direct
> subscriber of the question.
>

Revision history for this message
bloated_zebra_head (sethcall) said :
#9

Ok,

I tried the scripts and thy worked straight away! So, since I didn't have
to change txamqp itself at all, is it safe to assume that the scripts I was
trying are outdated in some way, or was I using them wrong?

Thanks much!

On Sun, Jan 25, 2009 at 8:12 AM, bloated_zebra_head <
<email address hidden>> wrote:

> Your question #57459 on txAMQP changed:
> https://answers.launchpad.net/txamqp/+question/57459
>
> Status: Needs information => Open
>
> You gave more information on the question:
> I did, but I was having some sort of other problem that I'm certain is
> of my own doing.
>
> Sorry for the delay; I'm going to clean up my dev environment and try
> again. I'll let you know how it goes ASAP.
>
>
> On Sun, Jan 25, 2009 at 5:33 AM, esteve
> <email address hidden> wrote:
> > Your question #57459 on txAMQP changed:
> > https://answers.launchpad.net/txamqp/+question/57459
> >
> > esteve requested for more information:
> > Did you have the chance to test those two scripts? Let me know how it
> > goes.
> >
> > --
> > To answer this request for more information, you can either reply to
> > this email or enter your reply at the following page:
> > https://answers.launchpad.net/txamqp/+question/57459
> >
> > You received this question notification because you are a direct
> > subscriber of the question.
> >
>
> --
> You received this question notification because you are a direct
> subscriber of the question.
>

Revision history for this message
bloated_zebra_head (sethcall) said :
#10

scripts provided by esteve work...