Merge lp:~soren/nova/rpc-call-concurrency into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Devin Carlen
Approved revision: 664
Merged at revision: 664
Proposed branch: lp:~soren/nova/rpc-call-concurrency
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 39 lines (+4/-4)
1 file modified
nova/rpc.py (+4/-4)
To merge this branch: bzr merge lp:~soren/nova/rpc-call-concurrency
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve
Jay Pipes (community) Approve
Review via email: mp+49373@code.launchpad.net

Commit message

Create a new AMQP connection by default.

Description of the change

It turns out that rpc.call has the same problem as rpc.cast. This time I saw it
when two clients attempted to call GetConsoleOutput at the same time.

I changed new's default to True and changed everywhere else to rely on the default.

I left the code implementing the singleton in, so that if we switch to another amqp
library that deals better with this, we can just change the default again.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

I'm not sure why there is even an option to set instance(False), but that's a separate gripe. This fixes the problem.

review: Approve
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/rpc.py'
2--- nova/rpc.py 2011-02-10 13:56:24 +0000
3+++ nova/rpc.py 2011-02-11 11:40:08 +0000
4@@ -46,7 +46,7 @@
5 class Connection(carrot_connection.BrokerConnection):
6 """Connection instance object"""
7 @classmethod
8- def instance(cls, new=False):
9+ def instance(cls, new=True):
10 """Returns the instance"""
11 if new or not hasattr(cls, '_instance'):
12 params = dict(hostname=FLAGS.rabbit_host,
13@@ -246,7 +246,7 @@
14 LOG.error(_("Returning exception %s to caller"), message)
15 LOG.error(tb)
16 failure = (failure[0].__name__, str(failure[1]), tb)
17- conn = Connection.instance(True)
18+ conn = Connection.instance()
19 publisher = DirectPublisher(connection=conn, msg_id=msg_id)
20 try:
21 publisher.send({'result': reply, 'failure': failure})
22@@ -319,7 +319,7 @@
23 self.result = data['result']
24
25 wait_msg = WaitMessage()
26- conn = Connection.instance(True)
27+ conn = Connection.instance()
28 consumer = DirectConsumer(connection=conn, msg_id=msg_id)
29 consumer.register_callback(wait_msg)
30
31@@ -346,7 +346,7 @@
32 """Sends a message on a topic without waiting for a response"""
33 LOG.debug(_("Making asynchronous cast..."))
34 _pack_context(msg, context)
35- conn = Connection.instance(True)
36+ conn = Connection.instance()
37 publisher = TopicPublisher(connection=conn, topic=topic)
38 publisher.send(msg)
39 publisher.close()