Message.create_messages should be a generator
Bug #1469324 reported by
Brian Curtin
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack SDK |
Invalid
|
High
|
Unassigned |
Bug Description
the Message.
Changed in python-openstacksdk: | |
status: | Confirmed → Invalid |
To post a comment you must log in.
I actually had it this way to begin with but ultimately left the yield out. Here's why.
As I was coding up the functional tests, I found I was just calling only
self. conn.message. create_ messages( messages)
a lot because I just need to create some messages and move on. If it succeeds, I don't really care too much about the result. I know the messages are on the queue and that's all I care about. Or raises an exception and I deal with it and there's no result to process in that case.
I expect this use case is pretty common. Fire and forget messages. It's the nature of queues.
But if it's a generator, I have to do something like
list( self.conn. message. create_ messages( messages) )
just to get it to run and actually make the call to create messages. I don't care about the result but I have to wrap it in list(). It seems like a gotcha to me. Someone could easily forget to wrap it and the messages never get created.
Also a generator doesn't add a lot of efficiency here either. The messages already consume whatever memory they do and we're just adding the href to them in the result.
And I haven't come across any other bulk create methods that return a generator as a precedent. The only one's I know of are the bulk create methods in Networks [1] but those don't seem to be implemented in the proxy.
I'm certainly open to discussing the implementation but am leaning towards leaving it as is for the reasons above.
[1] http:// developer. openstack. org/api- ref-networking- v2.html