_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q800
PubSubClient.retract
train
def retract(self, jid, node, id_, *, notify=False): """ Retract a previously published item from a node. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the PubSub node to send a notify from. :type node: :class:`str` ...
python
{ "resource": "" }
q801
PubSubClient.create
train
def create(self, jid, node=None): """ Create a new node at a service. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the PubSub node to create. :type node: :class:`str` or :data:`None` :raises aioxmpp.errors.XMPPEr...
python
{ "resource": "" }
q802
PubSubClient.delete
train
def delete(self, jid, node, *, redirect_uri=None): """ Delete an existing node. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the PubSub node to delete. :type node: :class:`str` or :data:`None` :param redirect_uri...
python
{ "resource": "" }
q803
PubSubClient.get_nodes
train
def get_nodes(self, jid, node=None): """ Request all nodes at a service or collection node. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the collection node to query :type node: :class:`str` or :data:`None` :rais...
python
{ "resource": "" }
q804
PubSubClient.get_node_affiliations
train
def get_node_affiliations(self, jid, node): """ Return the affiliations of other jids at a node. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the node to query :type node: :class:`str` :raises aioxmpp.errors.XMPP...
python
{ "resource": "" }
q805
PubSubClient.change_node_affiliations
train
def change_node_affiliations(self, jid, node, affiliations_to_set): """ Update the affiliations at a node. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the node to modify :type node: :class:`str` :param affiliati...
python
{ "resource": "" }
q806
PubSubClient.change_node_subscriptions
train
def change_node_subscriptions(self, jid, node, subscriptions_to_set): """ Update the subscriptions at a node. :param jid: Address of the PubSub service. :type jid: :class:`aioxmpp.JID` :param node: Name of the node to modify :type node: :class:`str` :param subscr...
python
{ "resource": "" }
q807
PubSubClient.purge
train
def purge(self, jid, node): """ Delete all items from a node. :param jid: JID of the PubSub service :param node: Name of the PubSub node :type node: :class:`str` Requires :attr:`.xso.Feature.PURGE`. """ iq = aioxmpp.stanza.IQ( type_=aioxmpp....
python
{ "resource": "" }
q808
Child.from_events
train
def from_events(self, instance, ev_args, ctx): """ Detect the object to instanciate from the arguments `ev_args` of the ``"start"`` event. The new object is stored at the corresponding descriptor attribute on `instance`. This method is suspendable. """ obj = yiel...
python
{ "resource": "" }
q809
XSOParser.add_class
train
def add_class(self, cls, callback): """ Add a class `cls` for parsing as root level element. When an object of `cls` type has been completely parsed, `callback` is called with the object as argument. """ if cls.TAG in self._tag_map: raise ValueError( ...
python
{ "resource": "" }
q810
check_bidi
train
def check_bidi(chars): """ Check proper bidirectionality as per stringprep. Operates on a list of unicode characters provided in `chars`. """ # the empty string is valid, as it cannot violate the RandALCat constraints if not chars: return # first_is_RorAL = unicodedata.bidirectiona...
python
{ "resource": "" }
q811
check_prohibited_output
train
def check_prohibited_output(chars, bad_tables): """ Check against prohibited output, by checking whether any of the characters from `chars` are in any of the `bad_tables`. Operates in-place on a list of code points from `chars`. """ violator = check_against_tables(chars, bad_tables) if viol...
python
{ "resource": "" }
q812
check_unassigned
train
def check_unassigned(chars, bad_tables): """ Check that `chars` does not contain any unassigned code points as per the given list of `bad_tables`. Operates on a list of unicode code points provided in `chars`. """ bad_tables = ( stringprep.in_table_a1,) violator = check_against_tab...
python
{ "resource": "" }
q813
AvatarSet.add_avatar_image
train
def add_avatar_image(self, mime_type, *, id_=None, image_bytes=None, width=None, height=None, url=None, nbytes=None): """ Add a source of the avatar image. All sources of an avatar image added to an avatar set must be *the same image*, i...
python
{ "resource": "" }
q814
AvatarService.get_avatar_metadata
train
def get_avatar_metadata(self, jid, *, require_fresh=False, disable_pep=False): """ Retrieve a list of avatar descriptors. :param jid: the JID for which to retrieve the avatar metadata. :type jid: :class:`aioxmpp.JID` :param require_fresh: if true, do ...
python
{ "resource": "" }
q815
AvatarService.publish_avatar_set
train
def publish_avatar_set(self, avatar_set): """ Make `avatar_set` the current avatar of the jid associated with this connection. If :attr:`synchronize_vcard` is true and PEP is available the vCard is only synchronized if the PEP update is successful. This means publishing...
python
{ "resource": "" }
q816
AvatarService.disable_avatar
train
def disable_avatar(self): """ Temporarily disable the avatar. If :attr:`synchronize_vcard` is true, the vCard avatar is disabled (even if disabling the PEP avatar fails). This is done by setting the avatar metadata node empty and if :attr:`synchronize_vcard` is true, do...
python
{ "resource": "" }
q817
AvatarService.wipe_avatar
train
def wipe_avatar(self): """ Remove all avatar data stored on the server. If :attr:`synchronize_vcard` is true, the vCard avatar is disabled even if disabling the PEP avatar fails. This is equivalent to :meth:`disable_avatar` for vCard-based avatars, but will also remove ...
python
{ "resource": "" }
q818
BlockingClient.block_jids
train
def block_jids(self, jids_to_block): """ Add the JIDs in the sequence `jids_to_block` to the client's blocklist. """ yield from self._check_for_blocking() if not jids_to_block: return cmd = blocking_xso.BlockCommand(jids_to_block) iq = aioxmp...
python
{ "resource": "" }
q819
BlockingClient.unblock_jids
train
def unblock_jids(self, jids_to_unblock): """ Remove the JIDs in the sequence `jids_to_block` from the client's blocklist. """ yield from self._check_for_blocking() if not jids_to_unblock: return cmd = blocking_xso.UnblockCommand(jids_to_unblock) ...
python
{ "resource": "" }
q820
DescriptorClass._register_descriptor_keys
train
def _register_descriptor_keys(self, descriptor, keys): """ Register the given descriptor keys for the given descriptor at the class. :param descriptor: The descriptor for which the `keys` shall be registered. :type descriptor: :class:`AbstractDescripto...
python
{ "resource": "" }
q821
FormClass.from_xso
train
def from_xso(self, xso): """ Construct and return an instance from the given `xso`. .. note:: This is a static method (classmethod), even though sphinx does not document it as such. :param xso: A :xep:`4` data form :type xso: :class:`~.Data` :rais...
python
{ "resource": "" }
q822
PEPClient.claim_pep_node
train
def claim_pep_node(self, node_namespace, *, register_feature=True, notify=False): """ Claim node `node_namespace`. :param node_namespace: the pubsub node whose events shall be handled. :param register_feature: Whether to publish the `node_namespace` ...
python
{ "resource": "" }
q823
PEPClient.available
train
def available(self): """ Check whether we have a PEP identity associated with our account. """ disco_info = yield from self._disco_client.query_info( self.client.local_jid.bare() ) for item in disco_info.identities.filter(attrs={"category": "pubsub"}): ...
python
{ "resource": "" }
q824
PEPClient.publish
train
def publish(self, node, data, *, id_=None, access_model=None): """ Publish an item `data` in the PubSub node `node` on the PEP service associated with the user's JID. :param node: The PubSub node to publish to. :param data: The item to publish. :type data: An XSO represe...
python
{ "resource": "" }
q825
RegisteredPEPNode.close
train
def close(self): """ Unclaim the PEP node and unregister the registered features. It is not necessary to call close if this claim is managed by :class:`~aioxmpp.pep.register_pep_node`. """ if self._closed: return self._closed = True self._pep...
python
{ "resource": "" }
q826
DjangoNode.full_clean
train
def full_clean(self, exclude, validate_unique=False): """ Validate node, on error raising ValidationErrors which can be handled by django forms :param exclude: :param validate_unique: Check if conflicting node exists in the labels indexes :return: """ # validate...
python
{ "resource": "" }
q827
AbstractUser.email_user
train
def email_user(self, subject, message, from_email=None): """ Send an email to this User.""" send_mail(subject, message, from_email, [self.email])
python
{ "resource": "" }
q828
UserAdmin.activate_users
train
def activate_users(self, request, queryset): """ Activates the selected users, if they are not already activated. """ n = 0 for user in queryset: if not user.is_active: user.activate() n += 1 self.message_user( ...
python
{ "resource": "" }
q829
UserAdmin.send_activation_email
train
def send_activation_email(self, request, queryset): """ Send activation emails for the selected users, if they are not already activated. """ n = 0 for user in queryset: if not user.is_active and settings.USERS_VERIFY_EMAIL: send_activation_ema...
python
{ "resource": "" }
q830
UserManager.get_queryset
train
def get_queryset(self): """ Fixes get_query_set vs get_queryset for Django <1.6 """ try: qs = super(UserManager, self).get_queryset() except AttributeError: # pragma: no cover qs = super(UserManager, self).get_query_set() return qs
python
{ "resource": "" }
q831
Poller.is_ready
train
def is_ready(self): """Is Socket Ready. :rtype: tuple """ try: ready, _, _ = self.select.select([self.fileno], [], [], POLL_TIMEOUT) return bool(ready) except self.select.error as why: if why.args[0...
python
{ "resource": "" }
q832
IO.close
train
def close(self): """Close Socket. :return: """ self._wr_lock.acquire() self._rd_lock.acquire() try: self._running.clear() if self.socket: self._close_socket() if self._inbound_thread: self._inbound_threa...
python
{ "resource": "" }
q833
IO.open
train
def open(self): """Open Socket and establish a connection. :raises AMQPConnectionError: Raises if the connection encountered an error. :return: """ self._wr_lock.acquire() self._rd_lock.acquire() try: self.data_in ...
python
{ "resource": "" }
q834
IO.write_to_socket
train
def write_to_socket(self, frame_data): """Write data to the socket. :param str frame_data: :return: """ self._wr_lock.acquire() try: total_bytes_written = 0 bytes_to_send = len(frame_data) while total_bytes_written < bytes_to_send: ...
python
{ "resource": "" }
q835
IO._close_socket
train
def _close_socket(self): """Shutdown and close the Socket. :return: """ try: self.socket.shutdown(socket.SHUT_RDWR) except (OSError, socket.error): pass self.socket.close()
python
{ "resource": "" }
q836
IO._get_socket_addresses
train
def _get_socket_addresses(self): """Get Socket address information. :rtype: list """ family = socket.AF_UNSPEC if not socket.has_ipv6: family = socket.AF_INET try: addresses = socket.getaddrinfo(self._parameters['hostname'], ...
python
{ "resource": "" }
q837
IO._find_address_and_connect
train
def _find_address_and_connect(self, addresses): """Find and connect to the appropriate address. :param addresses: :raises AMQPConnectionError: Raises if the connection encountered an error. :rtype: socket.socket """ error_message = ...
python
{ "resource": "" }
q838
IO._create_socket
train
def _create_socket(self, socket_family): """Create Socket. :param int socket_family: :rtype: socket.socket """ sock = socket.socket(socket_family, socket.SOCK_STREAM, 0) sock.settimeout(self._parameters['timeout'] or None) if self.use_ssl: if not comp...
python
{ "resource": "" }
q839
IO._ssl_wrap_socket
train
def _ssl_wrap_socket(self, sock): """Wrap SSLSocket around the Socket. :param socket.socket sock: :rtype: SSLSocket """ context = self._parameters['ssl_options'].get('context') if context is not None: hostname = self._parameters['ssl_options'].get('server_hos...
python
{ "resource": "" }
q840
IO._create_inbound_thread
train
def _create_inbound_thread(self): """Internal Thread that handles all incoming traffic. :rtype: threading.Thread """ inbound_thread = threading.Thread(target=self._process_incoming_data, name=__name__) inbound_thread.daemon = True ...
python
{ "resource": "" }
q841
IO._process_incoming_data
train
def _process_incoming_data(self): """Retrieve and process any incoming data. :return: """ while self._running.is_set(): if self.poller.is_ready: self.data_in += self._receive() self.data_in = self._on_read_impl(self.data_in)
python
{ "resource": "" }
q842
IO._receive
train
def _receive(self): """Receive any incoming socket data. If an error is thrown, handle it and return an empty string. :return: data_in :rtype: bytes """ data_in = EMPTY_BUFFER try: data_in = self._read_from_socket() except socket.timeout:...
python
{ "resource": "" }
q843
IO._read_from_socket
train
def _read_from_socket(self): """Read data from the socket. :rtype: bytes """ if not self.use_ssl: if not self.socket: raise socket.error('connection/socket error') return self.socket.recv(MAX_FRAME_SIZE) with self._rd_lock: if...
python
{ "resource": "" }
q844
Heartbeat.start
train
def start(self, exceptions): """Start the Heartbeat Checker. :param list exceptions: :return: """ if not self._interval: return False self._running.set() with self._lock: self._threshold = 0 self._reads_since_check = 0 ...
python
{ "resource": "" }
q845
Heartbeat.stop
train
def stop(self): """Stop the Heartbeat Checker. :return: """ self._running.clear() with self._lock: if self._timer: self._timer.cancel() self._timer = None
python
{ "resource": "" }
q846
Heartbeat._check_for_life_signs
train
def _check_for_life_signs(self): """Check Connection for life signs. First check if any data has been sent, if not send a heartbeat to the remote server. If we have not received any data what so ever within two intervals, we need to raise an exception so that we...
python
{ "resource": "" }
q847
Heartbeat._raise_or_append_exception
train
def _raise_or_append_exception(self): """The connection is presumably dead and we need to raise or append an exception. If we have a list for exceptions, append the exception and let the connection handle it, if not raise the exception here. :return: """ ...
python
{ "resource": "" }
q848
Heartbeat._start_new_timer
train
def _start_new_timer(self): """Create a timer that will be used to periodically check the connection for heartbeats. :return: """ if not self._running.is_set(): return False self._timer = self.timer_impl( interval=self._interval, funct...
python
{ "resource": "" }
q849
Queue.get
train
def get(self, queue, virtual_host='/'): """Get Queue details. :param queue: Queue name :param str virtual_host: Virtual host name :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. :...
python
{ "resource": "" }
q850
Queue.list
train
def list(self, virtual_host='/', show_all=False): """List Queues. :param str virtual_host: Virtual host name :param bool show_all: List all Queues :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity ...
python
{ "resource": "" }
q851
Queue.bindings
train
def bindings(self, queue, virtual_host='/'): """Get Queue bindings. :param str queue: Queue name :param str virtual_host: Virtual host name :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. ...
python
{ "resource": "" }
q852
Exchange.get
train
def get(self, exchange, virtual_host='/'): """Get Exchange details. :param str exchange: Exchange name :param str virtual_host: Virtual host name :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity i...
python
{ "resource": "" }
q853
Exchange.list
train
def list(self, virtual_host='/', show_all=False): """List Exchanges. :param str virtual_host: Virtual host name :param bool show_all: List all Exchanges :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connect...
python
{ "resource": "" }
q854
Exchange.bindings
train
def bindings(self, exchange, virtual_host='/'): """Get Exchange bindings. :param str exchange: Exchange name :param str virtual_host: Virtual host name :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connecti...
python
{ "resource": "" }
q855
Connection.check_for_errors
train
def check_for_errors(self): """Check Connection for errors. :raises AMQPConnectionError: Raises if the connection encountered an error. :return: """ if not self.exceptions: if not self.is_closed: return ...
python
{ "resource": "" }
q856
Connection.open
train
def open(self): """Open Connection. :raises AMQPConnectionError: Raises if the connection encountered an error. """ LOGGER.debug('Connection Opening') self.set_state(self.OPENING) self._exceptions = [] self._channels = {} ...
python
{ "resource": "" }
q857
Connection.write_frame
train
def write_frame(self, channel_id, frame_out): """Marshal and write an outgoing pamqp frame to the Socket. :param int channel_id: Channel ID. :param specification.Frame frame_out: Amqp frame. :return: """ frame_data = pamqp_frame.marshal(frame_out, channel_id) se...
python
{ "resource": "" }
q858
Connection.write_frames
train
def write_frames(self, channel_id, frames_out): """Marshal and write multiple outgoing pamqp frames to the Socket. :param int channel_id: Channel ID/ :param list frames_out: Amqp frames. :return: """ data_out = EMPTY_BUFFER for single_frame in frames_out: ...
python
{ "resource": "" }
q859
Connection._close_remaining_channels
train
def _close_remaining_channels(self): """Forcefully close all open channels. :return: """ for channel_id in list(self._channels): self._channels[channel_id].set_state(Channel.CLOSED) self._channels[channel_id].close() self._cleanup_channel(channel_id)
python
{ "resource": "" }
q860
Connection._handle_amqp_frame
train
def _handle_amqp_frame(self, data_in): """Unmarshal a single AMQP frame and return the result. :param data_in: socket data :return: data_in, channel_id, frame """ if not data_in: return data_in, None, None try: byte_count, channel_id, frame_in = ...
python
{ "resource": "" }
q861
Connection._read_buffer
train
def _read_buffer(self, data_in): """Process the socket buffer, and direct the data to the appropriate channel. :rtype: bytes """ while data_in: data_in, channel_id, frame_in = self._handle_amqp_frame(data_in) if frame_in is None: break ...
python
{ "resource": "" }
q862
Connection._cleanup_channel
train
def _cleanup_channel(self, channel_id): """Remove the the channel from the list of available channels. :param int channel_id: Channel id :return: """ with self.lock: if channel_id not in self._channels: return del self._channels[channel_i...
python
{ "resource": "" }
q863
Connection._validate_parameters
train
def _validate_parameters(self): """Validate Connection Parameters. :return: """ if not compatibility.is_string(self.parameters['hostname']): raise AMQPInvalidArgument('hostname should be a string') elif not compatibility.is_integer(self.parameters['port']): ...
python
{ "resource": "" }
q864
Connection._wait_for_connection_state
train
def _wait_for_connection_state(self, state=Stateful.OPEN, rpc_timeout=30): """Wait for a Connection state. :param int state: State that we expect :raises AMQPConnectionError: Raises if we are unable to establish a connection to RabbitMQ. :return: ...
python
{ "resource": "" }
q865
Consumer.start
train
def start(self): """Start the Consumers. :return: """ if not self.connection: self.create_connection() while True: try: channel = self.connection.channel() channel.queue.declare('simple_queue') channel.basic...
python
{ "resource": "" }
q866
ScalableConsumer.stop
train
def stop(self): """Stop all consumers. :return: """ while self._consumers: consumer = self._consumers.pop() consumer.stop() self._stopped.set() self._connection.close()
python
{ "resource": "" }
q867
ScalableConsumer._stop_consumers
train
def _stop_consumers(self, number_of_consumers=0): """Stop a specific number of consumers. :param number_of_consumers: :return: """ while len(self._consumers) > number_of_consumers: consumer = self._consumers.pop() consumer.stop()
python
{ "resource": "" }
q868
ScalableConsumer._start_consumer
train
def _start_consumer(self, consumer): """Start a consumer as a new Thread. :param Consumer consumer: :return: """ thread = threading.Thread(target=consumer.start, args=(self._connection,)) thread.daemon = True thread.start()
python
{ "resource": "" }
q869
Tx.select
train
def select(self): """Enable standard transaction mode. This will enable transaction mode on the channel. Meaning that messages will be kept in the remote server buffer until such a time that either commit or rollback is called. :return: """ self._tx_...
python
{ "resource": "" }
q870
Tx.rollback
train
def rollback(self): """Abandon the current transaction. Rollback all messages published during the current transaction session to the remote server. Note that all messages published during this transaction session will be lost, and will have to be published agai...
python
{ "resource": "" }
q871
rpc_call
train
def rpc_call(payload): """Simple Flask implementation for making asynchronous Rpc calls. """ # Send the request and store the requests Unique ID. corr_id = RPC_CLIENT.send_request(payload) # Wait until we have received a response. while RPC_CLIENT.queue[corr_id] is None: sleep(0.1) # ...
python
{ "resource": "" }
q872
RpcClient._create_process_thread
train
def _create_process_thread(self): """Create a thread responsible for consuming messages in response to RPC requests. """ thread = threading.Thread(target=self._process_data_events) thread.setDaemon(True) thread.start()
python
{ "resource": "" }
q873
Message.create
train
def create(channel, body, properties=None): """Create a new Message. :param Channel channel: AMQPStorm Channel :param bytes|str|unicode body: Message payload :param dict properties: Message properties :rtype: Message """ properties = properties or {} if ...
python
{ "resource": "" }
q874
Message.body
train
def body(self): """Return the Message Body. If auto_decode is enabled, the body will automatically be decoded using decode('utf-8') if possible. :rtype: bytes|str|unicode """ if not self._auto_decode: return self._body if 'body' in self._deco...
python
{ "resource": "" }
q875
Message.publish
train
def publish(self, routing_key, exchange='', mandatory=False, immediate=False): """Publish Message. :param str routing_key: Message routing key :param str exchange: The exchange to publish the message to :param bool mandatory: Requires the message is published :pa...
python
{ "resource": "" }
q876
Message._update_properties
train
def _update_properties(self, name, value): """Update properties, and keep cache up-to-date if auto decode is enabled. :param str name: Key :param obj value: Value :return: """ if self._auto_decode and 'properties' in self._decode_cache: self._decode_c...
python
{ "resource": "" }
q877
Message._try_decode_utf8_content
train
def _try_decode_utf8_content(self, content, content_type): """Generic function to decode content. :param object content: :return: """ if not self._auto_decode or not content: return content if content_type in self._decode_cache: return self._decod...
python
{ "resource": "" }
q878
Message._try_decode_dict
train
def _try_decode_dict(self, content): """Decode content of a dictionary. :param dict content: :return: """ result = dict() for key, value in content.items(): key = try_utf8_decode(key) if isinstance(value, dict): result[key] = self....
python
{ "resource": "" }
q879
Message._try_decode_list
train
def _try_decode_list(content): """Decode content of a list. :param list|tuple content: :return: """ result = list() for value in content: result.append(try_utf8_decode(value)) return result
python
{ "resource": "" }
q880
Basic.get
train
def get(self, queue, virtual_host='/', requeue=False, to_dict=False, count=1, truncate=50000, encoding='auto'): """Get Messages. :param str queue: Queue name :param str virtual_host: Virtual host name :param bool requeue: Re-queue message :param bool to_dict: Should ...
python
{ "resource": "" }
q881
VirtualHost.get
train
def get(self, virtual_host): """Get Virtual Host details. :param str virtual_host: Virtual host name :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. :rtype: dict """ virtu...
python
{ "resource": "" }
q882
VirtualHost.create
train
def create(self, virtual_host): """Create a Virtual Host. :param str virtual_host: Virtual host name :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. :rtype: dict """ virtu...
python
{ "resource": "" }
q883
VirtualHost.delete
train
def delete(self, virtual_host): """Delete a Virtual Host. :param str virtual_host: Virtual host name :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. :rtype: dict """ virtu...
python
{ "resource": "" }
q884
VirtualHost.get_permissions
train
def get_permissions(self, virtual_host): """Get all Virtual hosts permissions. :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. :rtype: dict """ virtual_host = quote(virtual_host, '...
python
{ "resource": "" }
q885
BaseChannel.add_consumer_tag
train
def add_consumer_tag(self, tag): """Add a Consumer tag. :param str tag: Consumer tag. :return: """ if not is_string(tag): raise AMQPChannelError('consumer tag needs to be a string') if tag not in self._consumer_tags: self._consumer_tags.append(tag...
python
{ "resource": "" }
q886
BaseChannel.remove_consumer_tag
train
def remove_consumer_tag(self, tag=None): """Remove a Consumer tag. If no tag is specified, all all tags will be removed. :param str|None tag: Consumer tag. :return: """ if tag is not None: if tag in self._consumer_tags: self._consumer_tag...
python
{ "resource": "" }
q887
BaseMessage.to_dict
train
def to_dict(self): """Message to Dictionary. :rtype: dict """ return { 'body': self._body, 'method': self._method, 'properties': self._properties, 'channel': self._channel }
python
{ "resource": "" }
q888
BaseMessage.to_tuple
train
def to_tuple(self): """Message to Tuple. :rtype: tuple """ return self._body, self._channel, self._method, self._properties
python
{ "resource": "" }
q889
Connection.close
train
def close(self, connection, reason='Closed via management api'): """Close Connection. :param str connection: Connection name :param str reason: Reason for closing connection. :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises ...
python
{ "resource": "" }
q890
Rpc.on_frame
train
def on_frame(self, frame_in): """On RPC Frame. :param specification.Frame frame_in: Amqp frame. :return: """ if frame_in.name not in self._request: return False uuid = self._request[frame_in.name] if self._response[uuid]: self._response[u...
python
{ "resource": "" }
q891
Rpc.register_request
train
def register_request(self, valid_responses): """Register a RPC request. :param list valid_responses: List of possible Responses that we should be waiting for. :return: """ uuid = str(uuid4()) self._response[uuid] = [] for acti...
python
{ "resource": "" }
q892
Rpc.get_request
train
def get_request(self, uuid, raw=False, multiple=False, connection_adapter=None): """Get a RPC request. :param str uuid: Rpc Identifier :param bool raw: If enabled return the frame as is, else return result as a dictionary. :param bool multipl...
python
{ "resource": "" }
q893
Rpc._get_response_frame
train
def _get_response_frame(self, uuid): """Get a response frame. :param str uuid: Rpc Identifier :return: """ frame = None frames = self._response.get(uuid, None) if frames: frame = frames.pop(0) return frame
python
{ "resource": "" }
q894
Rpc._wait_for_request
train
def _wait_for_request(self, uuid, connection_adapter=None): """Wait for RPC request to arrive. :param str uuid: Rpc Identifier. :param obj connection_adapter: Provide custom connection adapter. :return: """ start_time = time.time() while not self._response[uuid]:...
python
{ "resource": "" }
q895
Rpc._raise_rpc_timeout_error
train
def _raise_rpc_timeout_error(self, uuid): """Gather information and raise an Rpc exception. :param str uuid: Rpc Identifier. :return: """ requests = [] for key, value in self._request.items(): if value == uuid: requests.append(key) sel...
python
{ "resource": "" }
q896
get_default_ssl_version
train
def get_default_ssl_version(): """Get the highest support TLS version, if none is available, return None. :rtype: bool|None """ if hasattr(ssl, 'PROTOCOL_TLSv1_2'): return ssl.PROTOCOL_TLSv1_2 elif hasattr(ssl, 'PROTOCOL_TLSv1_1'): return ssl.PROTOCOL_TLSv1_1 elif hasattr(ssl, '...
python
{ "resource": "" }
q897
is_string
train
def is_string(obj): """Is this a string. :param object obj: :rtype: bool """ if PYTHON3: str_type = (bytes, str) else: str_type = (bytes, str, unicode) return isinstance(obj, str_type)
python
{ "resource": "" }
q898
is_integer
train
def is_integer(obj): """Is this an integer. :param object obj: :return: """ if PYTHON3: return isinstance(obj, int) return isinstance(obj, (int, long))
python
{ "resource": "" }
q899
try_utf8_decode
train
def try_utf8_decode(value): """Try to decode an object. :param value: :return: """ if not value or not is_string(value): return value elif PYTHON3 and not isinstance(value, bytes): return value elif not PYTHON3 and not isinstance(value, unicode): return value tr...
python
{ "resource": "" }