Note that there are some explanatory texts on larger screens.

plurals
  1. POPython Socket GetAddrInfo (GAI) Error
    primarykey
    data
    text
    <p>I'm running Python (2.7.2) on an embedded linux system has roughly this startup sequence: </p> <p>0) Reboot</p> <p>1) Wait 2 minutes</p> <p>2) Acquire network config via DHCP</p> <p>A daemon process uses <a href="http://pypi.python.org/pypi/ntplib/" rel="nofollow">ntplib</a> to acquire the current time and update its clock accordingly.</p> <pre><code>import ntplib # http://pypi.python.org/pypi/ntplib/ ... self.ntpClient = ntplib.NTPClient() ... def getDate(self): try: logging.info('Sending NTP request to %s' % ('pool.ntp.org')) response = self.ntpClient.request('pool.ntp.org') secs = time.localtime(response.tx_time) logging.info('Response returned') return secs except Exception, e: logging.exception(e) return RESULT_FAILURE </code></pre> <p>A problem arises if the daemon process begins trying to resolve address info <em>before</em> the dhcp has run (step 2). This continues to be an error even <strong>after</strong> the DHCP client has run.</p> <p>Here is the exception:</p> <pre><code>ERROR:[Errno 2] temporary failure in name resolution. Traceback (most recent call last): File "/home/root/ntp_manager/ntp_manager.py", line 34, in getDate response = self.ntpClient.request('pool.ntp.org') File "/usr/lib/python2.7/ntplib.py", line 265, in request addrinfo = socket.getaddrinfo(host, port)[0] gaierror: [Errno 2] temporary failure in name resolution. </code></pre> <p>However if the ntpClient makes its <em>first</em> attempt <em>after</em> the dhcp, then everything works fine.</p> <p>It's as if the error is a product of some sort of caching (?!)</p> <p>I've run out of ideas, some help would be much appreciated. </p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload