_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q247100 | trace_xray_subsegment | train | def trace_xray_subsegment(skip_args=False):
"""Can be applied to any function or method to be traced by X-Ray.
If `skip_args` is True, the arguments of the function won't be sent to
X-Ray.
"""
@wrapt.decorator
def wrapper(wrapped, instance, args, kwargs):
| python | {
"resource": ""
} |
q247101 | get_service_name | train | def get_service_name(wrapped, instance, args, kwargs):
"""Return the AWS service name the client is communicating with."""
if 'serviceAbbreviation' not in instance._service_model.metadata:
| python | {
"resource": ""
} |
q247102 | extract_aws_metadata | train | def extract_aws_metadata(wrapped, instance, args, kwargs, return_value):
"""Provide AWS metadata for improved visualization.
See documentation for this data structure:
http://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-aws
"""
response = return_value... | python | {
"resource": ""
} |
q247103 | xray_botocore_api_call | train | def xray_botocore_api_call(wrapped, instance, args, kwargs):
"""Wrapper around botocore's base client API call method."""
return generic_xray_wrapper(
wrapped, instance, args, kwargs,
| python | {
"resource": ""
} |
q247104 | extract_http_metadata | train | def extract_http_metadata(wrapped, instance, args, kwargs, return_value):
"""Provide HTTP request metadata for improved visualization.
See documentation for this data structure:
http://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-http
"""
response = r... | python | {
"resource": ""
} |
q247105 | xray_requests_send | train | def xray_requests_send(wrapped, instance, args, kwargs):
"""Wrapper around the requests library's low-level send method."""
return generic_xray_wrapper(
wrapped, instance, args, kwargs, | python | {
"resource": ""
} |
q247106 | SortingExtractor.set_unit_spike_features | train | def set_unit_spike_features(self, unit_id, feature_name, value):
'''This function adds a unit features data set under the given features
name to the given unit.
Parameters
----------
unit_id: int
The unit id for which the features will be set
feature_name: st... | python | {
"resource": ""
} |
q247107 | SortingExtractor.set_unit_property | train | def set_unit_property(self, unit_id, property_name, value):
'''This function adds a unit property data set under the given property
name to the given unit.
Parameters
----------
unit_id: int
The unit id for which the property will be set
property_name: str
... | python | {
"resource": ""
} |
q247108 | SortingExtractor.set_units_property | train | def set_units_property(self, *, unit_ids=None, property_name, values):
'''Sets unit property data for a list of units
Parameters
----------
unit_ids: list
The list of unit ids for which the property will be set
Defaults to get_unit_ids()
property_name: st... | python | {
"resource": ""
} |
q247109 | SortingExtractor.get_unit_property | train | def get_unit_property(self, unit_id, property_name):
'''This function rerturns the data stored under the property name given
from the given unit.
Parameters
----------
unit_id: int
The unit id for which the property will be returned
property_name: str
... | python | {
"resource": ""
} |
q247110 | SortingExtractor.get_units_property | train | def get_units_property(self, *, unit_ids=None, property_name):
'''Returns a list of values stored under the property name corresponding
to a list of units
Parameters
----------
unit_ids: list
The unit ids for which the property will be returned
Defaults t... | python | {
"resource": ""
} |
q247111 | SortingExtractor.get_unit_property_names | train | def get_unit_property_names(self, unit_id=None):
'''Get a list of property names for a given unit, or for all units if unit_id is None
Parameters
----------
unit_id: int
The unit id for which the property names will be returned
If None (default), will return prop... | python | {
"resource": ""
} |
q247112 | SortingExtractor.copy_unit_properties | train | def copy_unit_properties(self, sorting, unit_ids=None):
'''Copy unit properties from another sorting extractor to the current
sorting extractor.
Parameters
----------
sorting: SortingExtractor
The sorting extractor from which the properties will be copied
uni... | python | {
"resource": ""
} |
q247113 | SortingExtractor.copy_unit_spike_features | train | def copy_unit_spike_features(self, sorting, unit_ids=None):
'''Copy unit spike features from another sorting extractor to the current
sorting extractor.
Parameters
----------
sorting: SortingExtractor
The sorting extractor from which the spike features will be copied... | python | {
"resource": ""
} |
q247114 | RecordingExtractor.get_snippets | train | def get_snippets(self, *, reference_frames, snippet_len, channel_ids=None):
'''This function returns data snippets from the given channels that
are starting on the given frames and are the length of the given snippet
lengths before and after.
Parameters
----------
snippe... | python | {
"resource": ""
} |
q247115 | RecordingExtractor.set_channel_locations | train | def set_channel_locations(self, channel_ids, locations):
'''This function sets the location properties of each specified channel
id with the corresponding locations of the passed in locations list.
Parameters
----------
channel_ids: array_like
The channel ids (ints) ... | python | {
"resource": ""
} |
q247116 | RecordingExtractor.get_channel_locations | train | def get_channel_locations(self, channel_ids):
'''This function returns the location of each channel specifed by
channel_ids
Parameters
----------
channel_ids: array_like
The channel ids (ints) for which the locations will be returned
Returns
--------... | python | {
"resource": ""
} |
q247117 | RecordingExtractor.set_channel_groups | train | def set_channel_groups(self, channel_ids, groups):
'''This function sets the group property of each specified channel
id with the corresponding group of the passed in groups list.
Parameters
----------
channel_ids: array_like
The channel ids (ints) for which the grou... | python | {
"resource": ""
} |
q247118 | RecordingExtractor.get_channel_groups | train | def get_channel_groups(self, channel_ids):
'''This function returns the group of each channel specifed by
channel_ids
Parameters
----------
channel_ids: array_like
The channel ids (ints) for which the groups will be returned | python | {
"resource": ""
} |
q247119 | RecordingExtractor.set_channel_property | train | def set_channel_property(self, channel_id, property_name, value):
'''This function adds a property dataset to the given channel under the
property name.
Parameters
----------
channel_id: int
The channel id for which the property will be added
property_name: s... | python | {
"resource": ""
} |
q247120 | RecordingExtractor.get_channel_property | train | def get_channel_property(self, channel_id, property_name):
'''This function returns the data stored under the property name from
the given channel.
Parameters
----------
channel_id: int
The channel id for which the property will be returned
property_name: str... | python | {
"resource": ""
} |
q247121 | RecordingExtractor.add_epoch | train | def add_epoch(self, epoch_name, start_frame, end_frame):
'''This function adds an epoch to your recording extractor that tracks
a certain time period in your recording. It is stored in an internal
dictionary of start and end frame tuples.
Parameters
----------
epoch_name... | python | {
"resource": ""
} |
q247122 | RecordingExtractor.remove_epoch | train | def remove_epoch(self, epoch_name):
'''This function removes an epoch from your recording extractor.
Parameters
----------
epoch_name: str
The name of the epoch to be removed
'''
if isinstance(epoch_name, str):
if epoch_name in list(self._epochs.k... | python | {
"resource": ""
} |
q247123 | RecordingExtractor.get_epoch_names | train | def get_epoch_names(self):
'''This function returns a list of all the epoch names in your recording
Returns
----------
epoch_names: list
List of epoch names in the recording extractor
'''
epoch_names = list(self._epochs.keys())
if not epoch_names:
... | python | {
"resource": ""
} |
q247124 | RecordingExtractor.get_epoch_info | train | def get_epoch_info(self, epoch_name):
'''This function returns the start frame and end frame of the epoch
in a dict.
Parameters
----------
epoch_name: str
The name of the epoch to be returned
Returns
----------
epoch_info: dict
A ... | python | {
"resource": ""
} |
q247125 | RecordingExtractor.get_epoch | train | def get_epoch(self, epoch_name):
'''This function returns a SubRecordingExtractor which is a view to the
given epoch
Parameters
----------
epoch_name: str
The name of the epoch to be returned
Returns
----------
epoch_extractor: SubRecordingEx... | python | {
"resource": ""
} |
q247126 | CurationSortingExtractor.exclude_units | train | def exclude_units(self, unit_ids):
'''This function deletes roots from the curation tree according to the given unit_ids
Parameters
----------
unit_ids: list
The unit ids to be excluded
'''
root_ids = []
for i in range(len(self._roots)):
r... | python | {
"resource": ""
} |
q247127 | CurationSortingExtractor.merge_units | train | def merge_units(self, unit_ids):
'''This function merges two roots from the curation tree according to the given unit_ids. It creates a new unit_id and root
that has the merged roots as children.
Parameters
----------
unit_ids: list
The unit ids to be merged
... | python | {
"resource": ""
} |
q247128 | CurationSortingExtractor.split_unit | train | def split_unit(self, unit_id, indices):
'''This function splits a root from the curation tree according to the given unit_id and indices. It creates two new unit_ids
and roots that have the split root as a child. This function splits the spike train of the root by the given indices.
Parameters
... | python | {
"resource": ""
} |
q247129 | read_python | train | def read_python(path):
'''Parses python scripts in a dictionary
Parameters
----------
path: str
Path to file to parse
Returns
-------
metadata:
dictionary containing parsed file
'''
from six import exec_
path = Path(path).absolute()
assert path.is_file()
... | python | {
"resource": ""
} |
q247130 | save_probe_file | train | def save_probe_file(recording, probe_file, format=None, radius=100, dimensions=None):
'''Saves probe file from the channel information of the given recording
extractor
Parameters
----------
recording: RecordingExtractor
The recording extractor to save probe file from
probe_file: str
... | python | {
"resource": ""
} |
q247131 | write_binary_dat_format | train | def write_binary_dat_format(recording, save_path, time_axis=0, dtype=None, chunksize=None):
'''Saves the traces of a recording extractor in binary .dat format.
Parameters
----------
recording: RecordingExtractor
The recording extractor object to be saved in .dat format
save_path: str
... | python | {
"resource": ""
} |
q247132 | openBiocamFile | train | def openBiocamFile(filename, verbose=False):
"""Open a Biocam hdf5 file, read and return the recording info, pick te correct method to access raw data, and return this to the caller."""
rf = h5py.File(filename, 'r')
# Read recording variables
recVars = rf.require_group('3BRecInfo/3BRecVars/')
# bitD... | python | {
"resource": ""
} |
q247133 | countries | train | def countries():
'''
get country dictionar from pytz and add some extra.
'''
global _countries
if not _countries:
v = {}
_countries = v
try:
from pytz import country_names | python | {
"resource": ""
} |
q247134 | countryccys | train | def countryccys():
'''
Create a dictionary with keys given by countries ISO codes and values
given by their currencies
'''
global _country_ccys
if not _country_ccys:
v = {}
_country_ccys = v
ccys = currencydb()
| python | {
"resource": ""
} |
q247135 | set_country_map | train | def set_country_map(cfrom, cto, name=None, replace=True):
'''
Set a mapping between a country code to another code
'''
global _country_maps
cdb = countries()
cfrom = str(cfrom).upper()
c = cdb.get(cfrom)
if c:
if name:
c = name
cto = str(cto).upper()
i... | python | {
"resource": ""
} |
q247136 | set_new_country | train | def set_new_country(code, ccy, name):
'''
Add new country code to database
'''
code = str(code).upper()
cdb = countries()
if code in cdb:
raise CountryError('Country %s already | python | {
"resource": ""
} |
q247137 | TableDirective.run | train | def run(self):
"""
Implements the directive
"""
# Get content and options
data_path = self.arguments[0]
header = self.options.get('header', True)
bits = data_path.split('.')
name = bits[-1]
path = '.'.join(bits[:-1])
node = table_node()
... | python | {
"resource": ""
} |
q247138 | todate | train | def todate(val):
'''Convert val to a datetime.date instance by trying several
conversion algorithm.
If it fails it raise a ValueError exception.
'''
if not val:
raise ValueError("Value not provided")
if isinstance(val, datetime):
return val.date()
elif isinstance(val, date):
... | python | {
"resource": ""
} |
q247139 | Period.components | train | def components(self):
'''The period string'''
p = ''
neg = self.totaldays < 0
y = self.years
m = self.months
w = self.weeks
d = self.days
if y:
p = '%sY' % abs(y)
if m:
p = '%s%sM' % (p, abs(m))
| python | {
"resource": ""
} |
q247140 | Period.simple | train | def simple(self):
'''A string representation with only one period delimiter.'''
if self._days:
return '%sD' % | python | {
"resource": ""
} |
q247141 | ccy.swap | train | def swap(self, c2):
'''
put the order of currencies as market standard
'''
inv = False
c1 = self
if c1.order > c2.order:
| python | {
"resource": ""
} |
q247142 | ccy.as_cross | train | def as_cross(self, delimiter=''):
'''
Return a cross rate representation with respect USD.
@param delimiter: could be '' or '/' normally
'''
if self.order > usd_order:
| python | {
"resource": ""
} |
q247143 | MispServer.POST | train | def POST(self, path, body, xml=True):
"""
Raw POST to the MISP server
:param path: URL fragment (ie /events/)
:param body: HTTP Body (raw bytes)
:returns: HTTP raw content (as seen by :class:`requests.Response`)
"""
url = self._absolute_url(path)
headers ... | python | {
"resource": ""
} |
q247144 | MispServer.GET | train | def GET(self, path):
"""
Raw GET to the MISP server
:param path: URL fragment (ie /events/)
:returns: HTTP raw content (as seen by :class:`requests.Response`)
"""
url = self._absolute_url(path)
resp = requests.get(url, headers=self.headers, verify=self.verify_ssl... | python | {
"resource": ""
} |
q247145 | MispShadowAttribute.from_attribute | train | def from_attribute(attr):
"""
Converts an attribute into a shadow attribute.
:param attr: :class:`MispAttribute` instance to be converted
:returns: Converted :class:`MispShadowAttribute`
:example:
>>> server = MispServer()
>>> event = server.events.get(12)
| python | {
"resource": ""
} |
q247146 | MasterControlProgram.active_processes | train | def active_processes(self, use_cache=True):
"""Return a list of all active processes, pruning dead ones
:rtype: list
"""
LOGGER.debug('Checking active processes (cache: %s)', use_cache)
if self.can_use_process_cache(use_cache):
return self._active_cache[1]
a... | python | {
"resource": ""
} |
q247147 | MasterControlProgram.calculate_stats | train | def calculate_stats(self, data):
"""Calculate the stats data for our process level data.
:param data: The collected stats data to report on
:type data: dict
"""
timestamp = data['timestamp']
del data['timestamp']
# Iterate through the last poll results
... | python | {
"resource": ""
} |
q247148 | MasterControlProgram.can_use_process_cache | train | def can_use_process_cache(self, use_cache):
"""Returns True if the process cache can be used
:param bool use_cache: Override the logic to force non-cached values
:rtype: bool
"""
return (use_cache and | python | {
"resource": ""
} |
q247149 | MasterControlProgram.check_process_counts | train | def check_process_counts(self):
"""Check for the minimum consumer process levels and start up new
processes needed.
"""
LOGGER.debug('Checking minimum consumer process levels')
for name in self.consumers:
processes_needed = self.process_spawn_qty(name)
| python | {
"resource": ""
} |
q247150 | MasterControlProgram.collect_results | train | def collect_results(self, data_values):
"""Receive the data from the consumers polled and process it.
:param dict data_values: The poll data returned from the consumer
:type data_values: dict
"""
self.last_poll_results['timestamp'] = self.poll_data['timestamp']
# Get t... | python | {
"resource": ""
} |
q247151 | MasterControlProgram.consumer_stats_counter | train | def consumer_stats_counter():
"""Return a new consumer stats counter instance.
:rtype: dict
"""
return {
process.Process.ERROR: 0,
| python | {
"resource": ""
} |
q247152 | MasterControlProgram.get_consumer_process | train | def get_consumer_process(self, consumer, name):
"""Get the process object for the specified consumer and process name.
| python | {
"resource": ""
} |
q247153 | MasterControlProgram.get_consumer_cfg | train | def get_consumer_cfg(config, only, qty):
"""Get the consumers config, possibly filtering the config if only
or qty is set.
:param config: The consumers config section
:type config: helper.config.Config
:param str only: When set, filter to run only this | python | {
"resource": ""
} |
q247154 | MasterControlProgram.is_dead | train | def is_dead(self, proc, name):
"""Checks to see if the specified process is dead.
:param psutil.Process proc: The process to check
:param str name: The name of consumer
:rtype: bool
"""
LOGGER.debug('Checking %s (%r)', name, proc)
try:
status = proc.... | python | {
"resource": ""
} |
q247155 | MasterControlProgram.kill_processes | train | def kill_processes(self):
"""Gets called on shutdown by the timer when too much time has gone by,
calling the terminate method instead of nicely asking for the consumers
to stop.
"""
LOGGER.critical('Max shutdown exceeded, forcibly exiting')
processes = self.active_proce... | python | {
"resource": ""
} |
q247156 | MasterControlProgram.log_stats | train | def log_stats(self):
"""Output the stats to the LOGGER."""
if not self.stats.get('counts'):
if self.consumers:
LOGGER.info('Did not receive any stats data from children')
return
if self.poll_data['processes']:
LOGGER.warning('%i process(es) di... | python | {
"resource": ""
} |
q247157 | MasterControlProgram.new_consumer | train | def new_consumer(self, config, consumer_name):
"""Return a consumer dict for the given name and configuration.
:param dict config: The consumer configuration
:param | python | {
"resource": ""
} |
q247158 | MasterControlProgram.new_process | train | def new_process(self, consumer_name):
"""Create a new consumer instances
:param str consumer_name: The name of the consumer
:return tuple: (str, process.Process)
"""
process_name = '%s-%s' % (consumer_name,
| python | {
"resource": ""
} |
q247159 | MasterControlProgram.new_process_number | train | def new_process_number(self, name):
"""Increment the counter for the process id number for a given consumer
configuration.
:param str name: Consumer name
:rtype: int
"""
| python | {
"resource": ""
} |
q247160 | MasterControlProgram.on_sigchld | train | def on_sigchld(self, _signum, _unused_frame):
"""Invoked when a child sends up an SIGCHLD signal.
:param int _signum: The signal that was invoked
:param frame _unused_frame: The frame that was interrupted
"""
LOGGER.info('SIGCHLD received from child')
if not self.active... | python | {
"resource": ""
} |
q247161 | MasterControlProgram.on_timer | train | def on_timer(self, _signum, _unused_frame):
"""Invoked by the Poll timer signal.
:param int _signum: The signal that was invoked
:param frame _unused_frame: The frame that was interrupted
"""
if self.is_shutting_down:
LOGGER.debug('Polling timer fired while shutting... | python | {
"resource": ""
} |
q247162 | MasterControlProgram.poll | train | def poll(self):
"""Start the poll process by invoking the get_stats method of the
consumers. If we hit this after another interval without fully
processing, note it with a warning.
"""
self.set_state(self.STATE_ACTIVE)
# If we don't have any active consumers, spawn new ... | python | {
"resource": ""
} |
q247163 | MasterControlProgram.poll_results_check | train | def poll_results_check(self):
"""Check the polling results by checking to see if the stats queue is
empty. If it is not, try and collect stats. If it is set a timer to
call ourselves in _POLL_RESULTS_INTERVAL.
"""
if not self.consumers:
LOGGER.debug('Skipping poll re... | python | {
"resource": ""
} |
q247164 | MasterControlProgram.process_spawn_qty | train | def process_spawn_qty(self, name):
"""Return the number of processes to spawn for the given consumer name.
:param str name: The consumer name
| python | {
"resource": ""
} |
q247165 | MasterControlProgram.remove_consumer_process | train | def remove_consumer_process(self, consumer, name):
"""Remove all details for the specified consumer and process name.
:param str consumer: The consumer name
:param str name: The process name
"""
my_pid = os.getpid()
if name in self.consumers[consumer].processes.keys():
... | python | {
"resource": ""
} |
q247166 | MasterControlProgram.run | train | def run(self):
"""When the consumer is ready to start running, kick off all of our
consumer consumers and then loop while we process messages.
"""
self.set_state(self.STATE_ACTIVE)
self.setup_consumers()
# Set the SIGCHLD handler for child creation errors
signal... | python | {
"resource": ""
} |
q247167 | MasterControlProgram.set_process_name | train | def set_process_name():
"""Set the process name for the top level process so that it shows up
in logs in a more trackable fashion.
"""
proc = multiprocessing.current_process() | python | {
"resource": ""
} |
q247168 | MasterControlProgram.set_timer | train | def set_timer(self, duration):
"""Setup the next alarm to fire and then wait for it to fire.
:param int duration: How long to sleep
"""
# Make sure that the application | python | {
"resource": ""
} |
q247169 | MasterControlProgram.setup_consumers | train | def setup_consumers(self):
"""Iterate through each consumer in the configuration and kick off the
minimal amount of processes, setting up the runtime data as well.
"""
if not self.consumer_cfg:
LOGGER.warning('No consumers are configured')
for name in self.consumer_c... | python | {
"resource": ""
} |
q247170 | MasterControlProgram.start_process | train | def start_process(self, name):
"""Start a new consumer process for the given consumer name
:param str name: The consumer name
"""
process_name, proc = self.new_process(name)
LOGGER.info('Spawning %s process for %s', process_name, name)
| python | {
"resource": ""
} |
q247171 | MasterControlProgram.start_processes | train | def start_processes(self, name, quantity):
"""Start the specified quantity of consumer processes for the given
consumer.
:param str name: The consumer name
| python | {
"resource": ""
} |
q247172 | MasterControlProgram.stop_processes | train | def stop_processes(self):
"""Iterate through all of the consumer processes shutting them down."""
self.set_state(self.STATE_SHUTTING_DOWN)
LOGGER.info('Stopping consumer processes')
signal.signal(signal.SIGABRT, signal.SIG_IGN)
signal.signal(signal.SIGALRM, signal.SIG_IGN)
... | python | {
"resource": ""
} |
q247173 | add_parser_arguments | train | def add_parser_arguments():
"""Add options to the parser"""
argparser = parser.get()
argparser.add_argument('-P', '--profile',
action='store',
default=None,
dest='profile',
help='Profile the consumer ... | python | {
"resource": ""
} |
q247174 | Controller._master_control_program | train | def _master_control_program(self):
"""Return an instance of the MasterControlProgram.
:rtype: rejected.mcp.MasterControlProgram
"""
return mcp.MasterControlProgram(self.config,
| python | {
"resource": ""
} |
q247175 | Controller.setup | train | def setup(self):
"""Continue the run process blocking on MasterControlProgram.run"""
# If the app was invoked to specified to prepend the path, do so now
| python | {
"resource": ""
} |
q247176 | Controller.stop | train | def stop(self):
"""Shutdown the MCP and child processes cleanly"""
LOGGER.info('Shutting down controller')
self.set_state(self.STATE_STOP_REQUESTED)
# Clear out the timer
signal.setitimer(signal.ITIMER_PROF, 0, 0)
self._mcp.stop_processes()
if self._mcp.is_runn... | python | {
"resource": ""
} |
q247177 | Controller.run | train | def run(self):
"""Run the rejected Application"""
self.setup()
self._mcp = self._master_control_program()
try:
self._mcp.run()
except KeyboardInterrupt:
LOGGER.info('Caught CTRL-C, shutting down')
except Exception:
exc_info = sys.exc_in... | python | {
"resource": ""
} |
q247178 | Connection.connect | train | def connect(self):
"""Create the low-level AMQP connection to RabbitMQ.
:rtype: pika.adapters.tornado_connection.TornadoConnection
"""
self.set_state(self.STATE_CONNECTING)
self.handle = tornado_connection.TornadoConnection(
self._connection_parameters,
| python | {
"resource": ""
} |
q247179 | Connection.shutdown | train | def shutdown(self):
"""Start the connection shutdown process, cancelling any active
consuming and closing the channel if the connection is not active.
"""
if self.is_shutting_down:
self.logger.debug('Already shutting down')
return
self.set_state(self.STA... | python | {
"resource": ""
} |
q247180 | Connection.on_open | train | def on_open(self, _handle):
"""Invoked when the connection is opened
:type _handle: pika.adapters.tornado_connection.TornadoConnection
"""
self.logger.debug('Connection opened')
self.handle.add_on_connection_blocked_callback(self.on_blocked)
| python | {
"resource": ""
} |
q247181 | Connection.on_channel_open | train | def on_channel_open(self, channel):
"""This method is invoked by pika when the channel has been opened. It
will change the state to CONNECTED, add the callbacks and setup the
channel to start consuming.
:param pika.channel.Channel channel: The channel object
"""
self.lo... | python | {
"resource": ""
} |
q247182 | Connection.consume | train | def consume(self, queue_name, no_ack, prefetch_count):
"""Consume messages from RabbitMQ, changing the state, QoS and issuing
the RPC to RabbitMQ to start delivering messages.
:param str queue_name: The name of the queue to consume from
:param False no_ack: Enable no-ack mode
:p... | python | {
"resource": ""
} |
q247183 | Connection.on_consumer_cancelled | train | def on_consumer_cancelled(self, _frame):
"""Invoked by pika when a ``Basic.Cancel`` or ``Basic.CancelOk``
is received.
:param _frame: The Basic.Cancel or Basic.CancelOk | python | {
"resource": ""
} |
q247184 | Connection.on_confirmation | train | def on_confirmation(self, frame):
"""Invoked by pika when RabbitMQ responds to a Basic.Publish RPC
command, passing in either a Basic.Ack or Basic.Nack frame with
the delivery tag of the message that was published. The delivery tag
is an integer counter indicating the message number that... | python | {
"resource": ""
} |
q247185 | Connection.confirm_delivery | train | def confirm_delivery(self, delivery_tag, delivered):
"""Invoked by RabbitMQ when it is confirming delivery via a Basic.Ack
:param
:param int delivery_tag: The message # being confirmed
:param bool delivered: Was the message delivered
"""
for offset, msg in self.pending_... | python | {
"resource": ""
} |
q247186 | Connection.on_delivery | train | def on_delivery(self, channel, method, properties, body):
"""Invoked by pika when RabbitMQ delivers a message from a queue.
:param channel: The channel the message was delivered on
:type channel: pika.channel.Channel
:param method: The AMQP method frame
:type method: pika.frame.... | python | {
"resource": ""
} |
q247187 | Connection.on_return | train | def on_return(self, channel, method, properties, body):
"""Invoked by RabbitMQ when it returns a message that was published.
:param channel: The channel the message was delivered on
:type channel: pika.channel.Channel
:param method: The AMQP method frame
:type method: pika.frame... | python | {
"resource": ""
} |
q247188 | Connection.pending_confirmations | train | def pending_confirmations(self):
"""Return all published messages that have yet to be acked, nacked, or
returned.
:return: [(int, Published)]
"""
return sorted([(idx, msg)
| python | {
"resource": ""
} |
q247189 | Connection._connection_parameters | train | def _connection_parameters(self):
"""Return connection parameters for a pika connection.
:rtype: pika.ConnectionParameters
"""
return pika.ConnectionParameters(
self.config.get('host', 'localhost'),
self.config.get('port', 5672),
self.config.get('vho... | python | {
"resource": ""
} |
q247190 | SmartConsumer.publish_message | train | def publish_message(self,
exchange,
routing_key,
properties,
body,
no_serialization=False,
no_encoding=False,
channel=None,
conn... | python | {
"resource": ""
} |
q247191 | SmartConsumer.body | train | def body(self):
"""Return the message body, unencoded if needed,
deserialized if possible.
:rtype: any
"""
if self._message_body: # | python | {
"resource": ""
} |
q247192 | SmartConsumer._compress | train | def _compress(self, value, module_name):
"""Compress the value passed in using the named compression module.
:param bytes value: The uncompressed value
:rtype: bytes
"""
self.logger.debug('Decompressing with %s', module_name)
| python | {
"resource": ""
} |
q247193 | SmartConsumer._dump_csv | train | def _dump_csv(self, rows):
"""Take a list of dicts and return it as a CSV value. The
.. versionchanged:: 4.0.0
:param list rows: A list of lists to return as a CSV
:rtype: str
"""
self.logger.debug('Writing %r', rows)
| python | {
"resource": ""
} |
q247194 | SmartConsumer._maybe_decode | train | def _maybe_decode(self, value, encoding='utf-8'):
"""If a bytes object is passed in, in the Python 3 environment,
decode it using the specified encoding to turn it to a str instance.
:param mixed value: The value to possibly decode
:param str encoding: The encoding to use
:rtype... | python | {
"resource": ""
} |
q247195 | SmartConsumer._maybe_decompress_body | train | def _maybe_decompress_body(self):
"""Attempt to decompress the message body passed in using the named
compression module, if specified.
:rtype: bytes
"""
if self.content_encoding:
if self.content_encoding in self._CODEC_MAP.keys():
module_name = self... | python | {
"resource": ""
} |
q247196 | SmartConsumer._maybe_deserialize_body | train | def _maybe_deserialize_body(self):
"""Attempt to deserialize the message body based upon the content-type.
:rtype: mixed
"""
if not self.content_type:
return self._message_body
ct = headers.parse_content_type(self.content_type)
key = '{}/{}'.format(ct.conten... | python | {
"resource": ""
} |
q247197 | SmartConsumer._serialize | train | def _serialize(self, value, ct):
"""Auto-serialization of the value based upon the content-type value.
:param any value: The value to serialize
:param ietfparse.: The content type to serialize
:rtype: str
:raises: ValueError
"""
key = '{}/{}'.format(ct.content_t... | python | {
"resource": ""
} |
q247198 | GarbageCollector.collection_cycle | train | def collection_cycle(self, value):
"""Set the number of messages to process before invoking ``gc.collect``
:param int value: Cycle size
"""
if value is not None:
| python | {
"resource": ""
} |
q247199 | GarbageCollector.on_finish | train | def on_finish(self, exc=None):
"""Used to initiate the garbage collection"""
super(GarbageCollector, self).on_finish(exc)
self._cycles_left -= 1
if self._cycles_left <= 0:
num_collected = gc.collect()
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.