[getdns-users] Context.timeout in python-getdns

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Jan 18 02:15:46 UTC 2018


Hi getdns folks--

I'm using the python getdns bindings, and i've done something like
following:


    import getdns

    ctx = getdns.Context()
    ctx.timeout = 15000

    def callback(type, result, userarg, tid):
        pass

    def lookup_addresses(addresses):
        (addr, family) in addresses:
            q = { 'address_data': addr,
                  'address_type': 'IPv' + str(family) }
            ctx.hostname(q, userarg=addr, callback='callback')
        ctx.run()

    lookup_addresses([('192.0.2.5', 4), ('192.0.2.6', 4)])



The size and contents of the list passed to lookup_addresses() may vary,
and i invoke lookup_addresses() more than once in the lifetime of the
program.

When i time the "lookup_addresses" function, it sometimes takes far more than 15
seconds to complete, despite having set ctx.timeout to 15000.

and when i strace the process, i see some remarkable things, including
invocations of poll() with a timeout variable far greater than 15000,
like so:

    poll([{fd=5, events=POLLIN}, {fd=4, events=POLLIN}, {fd=-1}], 3, 67688)

and 4 and 5 are both UDP ports, with no other getdns-controlled file
descriptors open in the process.


Any idea what's going on?

    --dkg


PS: version information (debian packages on amd64):

libevent-core-2.1-6  2.1.8-stable-4
libgetdns6           1.2.1-2
python3-getdns       1.0.0~b1-1+b2





More information about the Users mailing list