def __init__(self, session, id, target, options): self.session = session self.id = id self.target = target self.options = options self.capacity = options.get("capacity", UNLIMITED) self.threshold = 0.5 self.durable = options.get("durable") self.queued = Serial(0) self.synced = Serial(0) self.acked = Serial(0) self.error = None self.linked = False self.closing = False self.closed = False self._lock = self.session._lock
def __init__(self, session, id, source, options): self.session = session self.id = id self.source = source self.options = options self.granted = Serial(0) self.draining = False self.impending = Serial(0) self.received = Serial(0) self.returned = Serial(0) self.error = None self.linked = False self.closing = False self.closed = False self._lock = self.session._lock self._capacity = 0 self._set_capacity(options.get("capacity", 0), False) self.threshold = 0.5
def __init__(self, url=None, **options): """ Creates a connection. A newly created connection must be connected with the Connection.connect() method before it can be used. @type url: str @param url: [ <username> [ / <password> ] @ ] <host> [ : <port> ] @type host: str @param host: the name or ip address of the remote host (overriden by url) @type port: int @param port: the port number of the remote host (overriden by url) @type transport: str @param transport: one of tcp, tcp+tls, or ssl (alias for tcp+tls) @type heartbeat: int @param heartbeat: heartbeat interval in seconds @type username: str @param username: the username for authentication (overriden by url) @type password: str @param password: the password for authentication (overriden by url) @type sasl_mechanisms: str @param sasl_mechanisms: space separated list of permitted sasl mechanisms @type sasl_service: str @param sasl_service: ??? @type sasl_min_ssf: ??? @param sasl_min_ssf: ??? @type sasl_max_ssf: ??? @param sasl_max_ssf: ??? @type reconnect: bool @param reconnect: enable/disable automatic reconnect @type reconnect_timeout: float @param reconnect_timeout: total time to attempt reconnect @type reconnect_internal_min: float @param reconnect_internal_min: minimum interval between reconnect attempts @type reconnect_internal_max: float @param reconnect_internal_max: maximum interval between reconnect attempts @type reconnect_internal: float @param reconnect_interval: set both min and max reconnect intervals @type reconnect_limit: int @param reconnect_limit: limit the total number of reconnect attempts @type reconnect_urls: list[str] @param reconnect_urls: list of backup hosts specified as urls @type address_ttl: float @param address_ttl: time until cached address resolution expires @type ssl_keyfile: str @param ssl_keyfile: file with client's private key (PEM format) @type ssl_certfile: str @param ssl_certfile: file with client's public (eventually priv+pub) key (PEM format) @type ssl_trustfile: str @param ssl_trustfile: file trusted certificates to validate the server @rtype: Connection @return: a disconnected Connection """ if url is None: url = options.get("host") if isinstance(url, basestring): url = URL(url) self.host = url.host if options.has_key("transport"): self.transport = options.get("transport") elif url.scheme == url.AMQP: self.transport = "tcp" elif url.scheme == url.AMQPS: self.transport = "ssl" else: self.transport = "tcp" if self.transport in ("ssl", "tcp+tls"): self.port = default(url.port, options.get("port", AMQPS_PORT)) else: self.port = default(url.port, options.get("port", AMQP_PORT)) self.heartbeat = options.get("heartbeat") self.username = default(url.user, options.get("username", None)) self.password = default(url.password, options.get("password", None)) self.auth_username = None self.sasl_mechanisms = options.get("sasl_mechanisms") self.sasl_service = options.get("sasl_service", "qpidd") self.sasl_min_ssf = options.get("sasl_min_ssf") self.sasl_max_ssf = options.get("sasl_max_ssf") self.reconnect = options.get("reconnect", False) self.reconnect_timeout = options.get("reconnect_timeout") reconnect_interval = options.get("reconnect_interval") self.reconnect_interval_min = options.get("reconnect_interval_min", default(reconnect_interval, 1)) self.reconnect_interval_max = options.get("reconnect_interval_max", default(reconnect_interval, 2*60)) self.reconnect_limit = options.get("reconnect_limit") self.reconnect_urls = options.get("reconnect_urls", []) self.reconnect_log = options.get("reconnect_log", True) self.address_ttl = options.get("address_ttl", 60) self.tcp_nodelay = options.get("tcp_nodelay", False) self.ssl_keyfile = options.get("ssl_keyfile", None) self.ssl_certfile = options.get("ssl_certfile", None) self.ssl_trustfile = options.get("ssl_trustfile", None) self.client_properties = options.get("client_properties", {}) self.options = options self.id = str(uuid4()) self.session_counter = 0 self.sessions = {} self._open = False self._connected = False self._transport_connected = False self._lock = RLock() self._condition = Condition(self._lock) self._waiter = Waiter(self._condition) self._modcount = Serial(0) self.error = None from driver import Driver self._driver = Driver(self)