benjaminws / python-stomp (http://just-another.net/python-stomp)

Implementation of the STOMP protocol in Python.

Clone this repository (size: 147.3 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/benjaminws/python-stomp/
follow

Hi!

I like the work you've done, and I particularly like that it *appears* I don't need to create a listener class to process messages. I'm writing an app that will support AMQP and STOMP (actually, the queuing protocol is pluggable). What I'd really like to see is an optional 'callback' argument to poll(). The value of 'callback' would be a python callable object that takes a stomp message as its only argument.

py-amqplib's basic_consume() does this exactly, and it's much cleaner than the stomppy regime which (afaict) requires a listener class with several methods defined. You can see line 165 here for a quick snippet: http://code.google.com/p/py-amqplib/source/browse/docs/overview.txt#165

Thanks for your work.

Status: resolved Responsible: Benjamin Smith / benjaminws Type: enhancement
Milestone: none Component: none Version: none

Attachments

No attachments added for this issue yet.

Comments and changes

#1

Brian Jones / m0j0

→ Changed type from bug to enhancement.

#2

Benjamin Smith / benjaminws

→ Changed responsible from nobody to benjaminws.

Really like this proposal! I'm on vacation this week from "real" work, so I'm going to branch off from the tip and get some tests written ASAP. Thanks!


#3

Benjamin Smith / benjaminws

→ Changed status from new to open.

Brian,

Take a look at r113:b354b45d62f2 and see if that meets your needs. You could do a pull from here and then hg up callback as I've done this in a separate branch.


#4

Brian Jones / m0j0

I haven't looked at the code itself, but for some reason this is happening:

File "build/bdist.macosx-10.6-universal/egg/stompy/stomp.py", line 209, in receive_frame self._callback(message, self)

It seems odd that receive_frame would pass an instance of self to the callback. Is there some really cool reason for that? Or, can we lose that? It should only get the message (at least in the model I'm using, and the one amqplib follows).

As an aside, I believe stompers are not constrained in the way that amqp'ers are: in amqp, basic_consume just tells the server "start sending messages -- here's the callback method", and then chan.wait() (with no args!) receives the messages and sends them to the callback function, so you have no option of having basic_consume just return messages to the calling code as they arrive like with receive_frame. Having that capability is nice, and I hope the callback doesn't get in the way of that. I don't think it will, since the callback arg seems to be optional -- just sayin' ;-)


#5

Brian Jones / m0j0

Ok, I took out the 'self' arg in receive_frame's call to self._callback. Works for me, though I've only tested in the context of my own code.


#6

Benjamin Smith / benjaminws

No fancy reason for it, late night code gremlins are likely the culprit.


#7

Brian Jones / m0j0

Ok - well ping me here or on twitter when the version with this change committed is released! I'd rather not go tracking branches on production boxen :-D

Thanks a bunch! brian


#8

Benjamin Smith / benjaminws

Prepping a release for this today. Sorry for the delay, I was pretty Ill, then I was pretty lazy ;-)


#9

Benjamin Smith / benjaminws

Released stompy-0.2.5 with the changes (sans passing self). Also fixed up documentation on http://packages.python.org/stompy/

If you're satisfied, I'd gladly close this issue.


#10 Anonymous

written 2 months ago, last edited unknown.

Thanks, Benjamin!

It'll be a week before I get to test this. I'll report back then, or (since anything I find is likely a bug and not a feature enhancement), I can open another ticket :)


#11

Benjamin Smith / benjaminws

→ Changed status from open to resolved.

Marking resolved for now.


Add comment / attachment

Show/hide preview

Verification: Please write the text from the image in the box (letters only)

captcha

Is that you, Humanoid? Is this me?