# eventlet.support package

## Submodules

## eventlet.support.greendns module

greendns - non-blocking DNS support for Eventlet

class eventlet.support.greendns.HostsAnswer(qname, rdtype, rdclass, rrset, raise_on_no_answer=True)

  Bases: `Answer`

  Answer class for HostsResolver object

class eventlet.support.greendns.HostsResolver(fname=None, interval=10.0)

  Bases: `object`

  Class to parse the hosts file

  ### Attributes

  fname:

    The filename of the hosts file in use.

  interval:

    The time between checking for hosts file modification

  LINES_RE = re.compile('\n \\s* # Leading space\n ([^\\r\\n#]*?) # The actual match, non-greedy so as not to include trailing space\n \\s* # Trailing space\n (?:[#][^\\r\\n]+)? # Comments\n , re.VERBOSE)
  getaliases(hostname)

    Return a list of all the aliases of a given cname

  query(qname, rdtype=RdataType.A, rdclass=RdataClass.IN, tcp=False, source=None, raise_on_no_answer=True)

    Query the hosts file

    The known rdtypes are dns.rdatatype.A, dns.rdatatype.AAAA and dns.rdatatype.CNAME.

    The `rdclass` parameter must be dns.rdataclass.IN while the `tcp` and `source` parameters are ignored.

    Return a HostAnswer instance or raise a dns.resolver.NoAnswer exception.

class eventlet.support.greendns.ResolverProxy(hosts_resolver=None, filename='/etc/resolv.conf')

  Bases: `object`

  Resolver class which can also use /etc/hosts

  Initialise with a HostsResolver instance in order for it to also use the hosts file.

  clear()
  getaliases(hostname)

    Return a list of all the aliases of a given hostname

  query(qname, rdtype=RdataType.A, rdclass=RdataClass.IN, tcp=False, source=None, raise_on_no_answer=True, _hosts_rdtypes=(RdataType.A, RdataType.AAAA), use_network=True)

    Query the resolver, using /etc/hosts if enabled.

    Behavior: 1. if hosts is enabled and contains answer, return it now 2. query nameservers for qname if use_network is True 3. if qname did not contain dots, pretend it was top-level domain,

    > query “foobar.” and append to previous result

eventlet.support.greendns.compute_expiration(query, timeout)

eventlet.support.greendns.getaddrinfo(host, port, family=0, type=0, proto=0, flags=0)

  Replacement for Python’s socket.getaddrinfo

  This does the A and AAAA lookups asynchronously after which it calls the OS’ getaddrinfo(3) using the AI_NUMERICHOST flag. This flag ensures getaddrinfo(3) does not use the network itself and allows us to respect all the other arguments like the native OS.

eventlet.support.greendns.getaliases(host)

  Return a list of for aliases for the given hostname

  This method does translate the dnspython exceptions into socket.gaierror exceptions. If no aliases are available an empty list will be returned.

eventlet.support.greendns.gethostbyname(hostname)

  Replacement for Python’s socket.gethostbyname

eventlet.support.greendns.gethostbyname_ex(hostname)

  Replacement for Python’s socket.gethostbyname_ex

eventlet.support.greendns.getnameinfo(sockaddr, flags)

  Replacement for Python’s socket.getnameinfo.

  Currently only supports IPv4.

eventlet.support.greendns.is_ip_addr(host)

  Return True if host is a valid IPv4 or IPv6 address

eventlet.support.greendns.is_ipv4_addr(host)

  Return True if host is a valid IPv4 address

eventlet.support.greendns.is_ipv6_addr(host)

  Return True if host is a valid IPv6 address

eventlet.support.greendns.reset()

eventlet.support.greendns.resolve(name, family=AddressFamily.AF_INET, raises=True, _proxy=None, use_network=True)

  Resolve a name for a given family using the global resolver proxy.

  This method is called by the global getaddrinfo() function. If use_network is False, only resolution via hosts file will be performed.

  Return a dns.resolver.Answer instance. If there is no answer it’s rrset will be emtpy.

eventlet.support.greendns.resolve_cname(host)

  Return the canonical name of a hostname

eventlet.support.greendns.tcp(q, where, timeout=10.0, port=53, af=None, source=None, source_port=0, one_rr_per_rrset=False, ignore_trailing=False, sock=None)

  coro friendly replacement for dns.query.tcp Return the response obtained after sending a query via TCP.

  @param q: the query @type q: dns.message.Message object @param where: where to send the message @type where: string containing an IPv4 or IPv6 address @param timeout: The number of seconds to wait before the query times out. If None, the default, wait forever. @type timeout: float @param port: The port to which to send the message. The default is 53. @type port: int @param af: the address family to use. The default is None, which causes the address family to use to be inferred from the form of of where. If the inference attempt fails, AF_INET is used. @type af: int @rtype: dns.message.Message object @param source: source address. The default is the IPv4 wildcard address. @type source: string @param source_port: The port from which to send the message. The default is 0. @type source_port: int @type ignore_unexpected: bool @param one_rr_per_rrset: If True, put each RR into its own RRset. @type one_rr_per_rrset: bool @param ignore_trailing: If True, ignore trailing junk at end of the received message. @type ignore_trailing: bool @param sock: the socket to use for the query. If None, the default, a socket is created. Note that if a socket is provided, it must be a nonblocking datagram socket, and the source and source_port are ignored. @type sock: socket.socket | None

eventlet.support.greendns.udp(q, where, timeout=10.0, port=53, af=None, source=None, source_port=0, ignore_unexpected=False, one_rr_per_rrset=False, ignore_trailing=False, raise_on_truncation=False, sock=None, ignore_errors=False)

  coro friendly replacement for dns.query.udp Return the response obtained after sending a query via UDP.

  @param q: the query @type q: dns.message.Message @param where: where to send the message @type where: string containing an IPv4 or IPv6 address @param timeout: The number of seconds to wait before the query times out. If None, the default, wait forever. @type timeout: float @param port: The port to which to send the message. The default is 53. @type port: int @param af: the address family to use. The default is None, which causes the address family to use to be inferred from the form of of where. If the inference attempt fails, AF_INET is used. @type af: int @rtype: dns.message.Message object @param source: source address. The default is the IPv4 wildcard address. @type source: string @param source_port: The port from which to send the message. The default is 0. @type source_port: int @param ignore_unexpected: If True, ignore responses from unexpected sources. The default is False. @type ignore_unexpected: bool @param one_rr_per_rrset: If True, put each RR into its own RRset. @type one_rr_per_rrset: bool @param ignore_trailing: If True, ignore trailing junk at end of the received message. @type ignore_trailing: bool @param raise_on_truncation: If True, raise an exception if the TC bit is set. @type raise_on_truncation: bool @param sock: the socket to use for the query. If None, the default, a socket is created. Note that if a socket is provided, it must be a nonblocking datagram socket, and the source and source_port are ignored. @type sock: socket.socket | None @param ignore_errors: if various format errors or response mismatches occur, continue listening. @type ignore_errors: bool

## eventlet.support.greenlets module

## eventlet.support.psycopg2_patcher module

## eventlet.support.pylib module

## eventlet.support.stacklesspypys module

## eventlet.support.stacklesss module

## Module contents

eventlet.support.bytes_to_str(b, encoding='ascii')

eventlet.support.get_errno(exc)

  Get the error code out of socket.error objects. socket.error in <2.5 does not have errno attribute socket.error in 3.x does not allow indexing access e.args[0] works for all. There are cases when args[0] is not errno. i.e. http://bugs.python.org/issue6471 Maybe there are cases when errno is set, but it is not the first argument?

eventlet.support.wrap_deprecated(old, new)