Hi,

I have recently run into an issue at work where we are having intermittent 
problems with an internal website not loading due to an interrupted system 
call. We are using urllib2 to access the website. I can't share the exact code, 
but here is basically how we do it:

payload = {'userName': user_name,
          'emailAddress': email_address,
          'password': password}
headers = {'Accept': 'application/json',
               'Content-Type': 'application/json',
               'Authorization': token}
values = json.dumps(payload)
req = urllib2.Request(url, values, headers)

try:
     response = urllib2.urlopen(req, timeout=30)
     break
except IOError, e:
    if e.errno != errno.EINTR:
        print e.errno
    raise

We log the errono and the raised exception. The exception is:

IOError: <urlopen error [Errno 4] Interrupted system call>

And the errno is None. I expected it to be 4.

Is there a better way to catch this error in Python 2? I am aware of PEP475, 
but we cannot upgrade to Python 3 right now.

Thanks,
Mike

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to