~sandy-walsh/nova/zones

« back to all changes in this revision

Viewing changes to nova/rpc.py

  • Committer: Sandy Walsh
  • Date: 2011-02-17 21:39:03 UTC
  • mfrom: (635.1.60 nova)
  • Revision ID: sandy.walsh@rackspace.com-20110217213903-swehe88wea8inxow
changed from 003-004 migration

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
from carrot import connection as carrot_connection
31
31
from carrot import messaging
 
32
from eventlet import greenpool
32
33
from eventlet import greenthread
33
34
 
34
35
from nova import context
42
43
FLAGS = flags.FLAGS
43
44
LOG = logging.getLogger('nova.rpc')
44
45
 
 
46
flags.DEFINE_integer('rpc_thread_pool_size', 1024, 'Size of RPC thread pool')
 
47
 
45
48
 
46
49
class Connection(carrot_connection.BrokerConnection):
47
50
    """Connection instance object"""
155
158
    def __init__(self, connection=None, topic="broadcast", proxy=None):
156
159
        LOG.debug(_('Initing the Adapter Consumer for %s') % topic)
157
160
        self.proxy = proxy
 
161
        self.pool = greenpool.GreenPool(FLAGS.rpc_thread_pool_size)
158
162
        super(AdapterConsumer, self).__init__(connection=connection,
159
163
                                              topic=topic)
160
164
 
 
165
    def receive(self, *args, **kwargs):
 
166
        self.pool.spawn_n(self._receive, *args, **kwargs)
 
167
 
161
168
    @exception.wrap_exception
162
 
    def receive(self, message_data, message):
 
169
    def _receive(self, message_data, message):
163
170
        """Magically looks for a method on the proxy object and calls it
164
171
 
165
172
        Message data should be a dictionary with two keys: