def __init__(self, remote_address, auth=None, client_name=None, loop=None, debug=False, error_policy=None, keep_alive_interval=None, **kwargs): if loop: self.loop = loop else: try: if not self.loop: # from sub class instance self.loop = get_running_loop() except AttributeError: self.loop = get_running_loop() super(AMQPClientAsync, self).__init__(remote_address, auth=auth, client_name=client_name, debug=debug, error_policy=error_policy, keep_alive_interval=keep_alive_interval, **kwargs) # AMQP object settings self.connection_type = ConnectionAsync self.session_type = SessionAsync
def __init__( self, target, auth=None, client_name=None, loop=None, debug=False, msg_timeout=0, error_policy=None, keep_alive_interval=None, **kwargs): self.loop = loop or get_running_loop() client.SendClient.__init__( self, target, auth=auth, client_name=client_name, debug=debug, msg_timeout=msg_timeout, error_policy=error_policy, keep_alive_interval=keep_alive_interval, **kwargs) # AMQP object settings self.sender_type = MessageSenderAsync self._pending_messages_lock = asyncio.Lock(loop=self.loop)
def __init__(self, source, auth=None, client_name=None, loop=None, debug=False, timeout=0, auto_complete=True, error_policy=None, keep_alive_interval=None, **kwargs): self.loop = loop or get_running_loop() client.ReceiveClient.__init__(self, source, auth=auth, client_name=client_name, debug=debug, timeout=timeout, auto_complete=auto_complete, error_policy=error_policy, keep_alive_interval=keep_alive_interval, **kwargs) # AMQP object settings self.receiver_type = MessageReceiverAsync
def __init__(self, session, source, target, name=None, send_settle_mode=constants.SenderSettleMode.Unsettled, receive_settle_mode=constants.ReceiverSettleMode.PeekLock, max_message_size=constants.MAX_MESSAGE_LENGTH_BYTES, link_credit=None, properties=None, error_policy=None, debug=False, encoding='UTF-8', loop=None): self.loop = loop or get_running_loop() super(MessageSenderAsync, self).__init__(session, source, target, name=name, send_settle_mode=send_settle_mode, receive_settle_mode=receive_settle_mode, max_message_size=max_message_size, link_credit=link_credit, properties=properties, error_policy=error_policy, debug=debug, encoding=encoding)
def __init__(self, session, source, target, on_message_received, name=None, receive_settle_mode=constants.ReceiverSettleMode.PeekLock, send_settle_mode=constants.SenderSettleMode.Unsettled, max_message_size=constants.MAX_MESSAGE_LENGTH_BYTES, prefetch=300, properties=None, error_policy=None, debug=False, encoding='UTF-8', desired_capabilities=None, loop=None): self.loop = loop or get_running_loop() super(MessageReceiverAsync, self).__init__(session, source, target, on_message_received, name=name, receive_settle_mode=receive_settle_mode, send_settle_mode=send_settle_mode, max_message_size=max_message_size, prefetch=prefetch, properties=properties, error_policy=error_policy, debug=debug, encoding=encoding, desired_capabilities=desired_capabilities)
def __init__(self, hostname, sasl, container_id=False, max_frame_size=None, channel_max=None, idle_timeout=None, properties=None, remote_idle_timeout_empty_frame_send_ratio=None, error_policy=None, debug=False, encoding='UTF-8', loop=None): self.loop = loop or get_running_loop() super(ConnectionAsync, self).__init__(hostname, sasl, container_id=container_id, max_frame_size=max_frame_size, channel_max=channel_max, idle_timeout=idle_timeout, properties=properties, remote_idle_timeout_empty_frame_send_ratio= remote_idle_timeout_empty_frame_send_ratio, error_policy=error_policy, debug=debug, encoding=encoding) self._async_lock = asyncio.Lock(loop=self.loop) self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
def get_dict_with_loop_if_needed(loop): if sys.version_info >= (3, 10) and loop: raise ValueError( "Starting Python 3.10, asyncio no longer supports loop as a parameter." ) return { 'loop': loop or get_running_loop() } if sys.version_info < (3, 10) else {}
def __init__(self, connection, incoming_window=None, outgoing_window=None, handle_max=None, on_attach=None, loop=None): self.loop = loop or get_running_loop() super(SessionAsync, self).__init__(connection, incoming_window=incoming_window, outgoing_window=outgoing_window, handle_max=handle_max, on_attach=on_attach)
def __init__(self, session, target=None, debug=False, status_code_field=b'statusCode', description_fields=b'statusDescription', encoding='UTF-8', loop=None): self.loop = loop or get_running_loop() super(MgmtOperationAsync, self).__init__(session, target=target, debug=debug, status_code_field=status_code_field, description_fields=description_fields, encoding=encoding)
async def create_authenticator_async(self, connection, debug=False, loop=None, **kwargs): """Create the async AMQP session and the CBS channel with which to negotiate the token. :param connection: The underlying AMQP connection on which to create the session. :type connection: ~uamqp.async_ops.connection_async.ConnectionAsync :param debug: Whether to emit network trace logging events for the CBS session. Default is `False`. Logging events are set at INFO level. :type debug: bool :param loop: A user specified event loop. :type loop: ~asycnio.AbstractEventLoop :rtype: uamqp.c_uamqp.CBSTokenAuth """ self.loop = loop or get_running_loop() self._connection = connection self._session = SessionAsync(connection, loop=self.loop, **kwargs) if self.token_type == b'jwt': # Async initialize the jwt token await self.update_token() try: self._cbs_auth = c_uamqp.CBSTokenAuth( self.audience, self.token_type, self.token, int(self.expires_at), self._session._session, # pylint: disable=protected-access self.timeout, self._connection.container_id) self._cbs_auth.set_trace(debug) except ValueError: await self._session.destroy_async() raise errors.AMQPConnectionError( "Unable to open authentication session on connection {}.\n" "Please confirm target hostname exists: {}".format( connection.container_id, connection.hostname)) from None return self._cbs_auth