~ubuntu-branches/ubuntu/vivid/ceilometer/vivid

« back to all changes in this revision

Viewing changes to ceilometer/openstack/common/rpc/__init__.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-03-06 14:44:28 UTC
  • mto: (28.1.1 utopic-proposed) (1.2.1)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: package-import@ubuntu.com-20140306144428-rvphsh4igwyulzf0
Tags: upstream-2014.1~b3
ImportĀ upstreamĀ versionĀ 2014.1~b3

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    rpc.proxy
24
24
"""
25
25
 
26
 
import inspect
27
 
 
28
26
from oslo.config import cfg
29
27
 
30
 
from ceilometer.openstack.common.gettextutils import _
31
28
from ceilometer.openstack.common import importutils
32
 
from ceilometer.openstack.common import local
33
29
from ceilometer.openstack.common import log as logging
34
30
 
35
31
 
93
89
    return _get_impl().create_connection(CONF, new=new)
94
90
 
95
91
 
96
 
def _check_for_lock():
97
 
    if not CONF.debug:
98
 
        return None
99
 
 
100
 
    if ((hasattr(local.strong_store, 'locks_held')
101
 
         and local.strong_store.locks_held)):
102
 
        stack = ' :: '.join([frame[3] for frame in inspect.stack()])
103
 
        LOG.warn(_('A RPC is being made while holding a lock. The locks '
104
 
                   'currently held are %(locks)s. This is probably a bug. '
105
 
                   'Please report it. Include the following: [%(stack)s].'),
106
 
                 {'locks': local.strong_store.locks_held,
107
 
                  'stack': stack})
108
 
        return True
109
 
 
110
 
    return False
111
 
 
112
 
 
113
 
def call(context, topic, msg, timeout=None, check_for_lock=False):
 
92
def call(context, topic, msg, timeout=None):
114
93
    """Invoke a remote method that returns something.
115
94
 
116
95
    :param context: Information that identifies the user that has made this
124
103
                                             "args" : dict_of_kwargs }
125
104
    :param timeout: int, number of seconds to use for a response timeout.
126
105
                    If set, this overrides the rpc_response_timeout option.
127
 
    :param check_for_lock: if True, a warning is emitted if a RPC call is made
128
 
                    with a lock held.
129
106
 
130
107
    :returns: A dict from the remote method.
131
108
 
132
109
    :raises: openstack.common.rpc.common.Timeout if a complete response
133
110
             is not received before the timeout is reached.
134
111
    """
135
 
    if check_for_lock:
136
 
        _check_for_lock()
137
112
    return _get_impl().call(CONF, context, topic, msg, timeout)
138
113
 
139
114
 
176
151
    return _get_impl().fanout_cast(CONF, context, topic, msg)
177
152
 
178
153
 
179
 
def multicall(context, topic, msg, timeout=None, check_for_lock=False):
 
154
def multicall(context, topic, msg, timeout=None):
180
155
    """Invoke a remote method and get back an iterator.
181
156
 
182
157
    In this case, the remote method will be returning multiple values in
194
169
                                             "args" : dict_of_kwargs }
195
170
    :param timeout: int, number of seconds to use for a response timeout.
196
171
                    If set, this overrides the rpc_response_timeout option.
197
 
    :param check_for_lock: if True, a warning is emitted if a RPC call is made
198
 
                    with a lock held.
199
172
 
200
173
    :returns: An iterator.  The iterator will yield a tuple (N, X) where N is
201
174
              an index that starts at 0 and increases by one for each value
205
178
    :raises: openstack.common.rpc.common.Timeout if a complete response
206
179
             is not received before the timeout is reached.
207
180
    """
208
 
    if check_for_lock:
209
 
        _check_for_lock()
210
181
    return _get_impl().multicall(CONF, context, topic, msg, timeout)
211
182
 
212
183