text
stringlengths 0
828
|
|---|
if result and 'cited_by' in result and metaonly is True:
|
del(result['cited_by'])
|
return result
|
if result:
|
return result
|
result = self.client.citedby_pid(pid, metaonly=metaonly)
|
try:
|
return json.loads(result)
|
except:
|
return None"
|
558,"def search(self, dsl, params):
|
""""""
|
Free queries to ES index.
|
dsl (string): with DSL query
|
params (list): [(key, value), (key, value)]
|
where key is a query parameter, and value is the value required for parameter, ex: [('size', '0'), ('search_type', 'count')]
|
""""""
|
query_parameters = []
|
for key, value in params:
|
query_parameters.append(self.CITEDBY_THRIFT.kwargs(str(key), str(value)))
|
try:
|
result = self.client.search(dsl, query_parameters)
|
except self.CITEDBY_THRIFT.ServerError:
|
raise ServerError('you may trying to run a bad DSL Query')
|
try:
|
return json.loads(result)
|
except:
|
return None"
|
559,"def raise_error(error):
|
""""""Intakes a dict of remote error information and raises a DashiError
|
""""""
|
exc_type = error.get('exc_type')
|
if exc_type and exc_type.startswith(ERROR_PREFIX):
|
exc_type = exc_type[len(ERROR_PREFIX):]
|
exc_cls = ERROR_TYPE_MAP.get(exc_type, DashiError)
|
else:
|
exc_cls = DashiError
|
raise exc_cls(**error)"
|
560,"def fire(self, name, operation, args=None, **kwargs):
|
""""""Send a message without waiting for a reply
|
@param name: name of destination service queue
|
@param operation: name of service operation to invoke
|
@param args: dictionary of keyword args to pass to operation.
|
Use this OR kwargs.
|
@param kwargs: additional args to pass to operation
|
""""""
|
if args:
|
if kwargs:
|
raise TypeError(""specify args dict or keyword arguments, not both"")
|
else:
|
args = kwargs
|
d = dict(op=operation, args=args)
|
headers = {'sender': self.add_sysname(self.name)}
|
dest = self.add_sysname(name)
|
def _fire(channel):
|
with Producer(channel) as producer:
|
producer.publish(d, routing_key=dest,
|
headers=headers, serializer=self._serializer,
|
exchange=self._exchange, declare=[self._exchange])
|
log.debug(""sending message to %s"", dest)
|
with connections[self._pool_conn].acquire(block=True) as conn:
|
_, channel = self.ensure(conn, _fire)
|
conn.maybe_close_channel(channel)"
|
561,"def call(self, name, operation, timeout=10, args=None, **kwargs):
|
""""""Send a message and wait for reply
|
@param name: name of destination service queue
|
@param operation: name of service operation to invoke
|
@param timeout: RPC timeout to await a reply
|
@param args: dictionary of keyword args to pass to operation.
|
Use this OR kwargs.
|
@param kwargs: additional args to pass to operation
|
""""""
|
if args:
|
if kwargs:
|
raise TypeError(""specify args dict or keyword arguments, not both"")
|
else:
|
args = kwargs
|
# create a direct queue for the reply. This may end up being a
|
# bottleneck for performance: each rpc call gets a brand new
|
# exclusive queue. However this approach is used nova.rpc and
|
# seems to have carried them pretty far. If/when this
|
# becomes a bottleneck we can set up a long-lived backend queue and
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.