def _call_api(self, api_url, err_env):
while True:  <EOL><INDENT>api_request = urllib2.Request(<EOL>api_url, headers={"<STR_LIT>": "<STR_LIT>"})<EOL>log.debug("<STR_LIT>" % api_url)<EOL>try:<EOL><INDENT>if self.Timeout and sys.version[:<NUM_LIT:3>] in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>old_timeout = socket.getdefaulttimeout()<EOL>try:<EOL><INDENT>socket.setdefaulttimeout(self.Timeout)<EOL>return urllib2.urlopen(api_request)<EOL><DEDENT>finally:<EOL><INDENT>socket.setdefaulttimeout(old_timeout)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return urllib2.urlopen(api_request, timeout=self.Timeout)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>if not self.ErrorHandler:<EOL><INDENT>raise<EOL><DEDENT>exception = sys.exc_info()[<NUM_LIT:1>]  <EOL>err = {'<STR_LIT>': exception}<EOL>err.update(err_env)<EOL>if not self.ErrorHandler(err):<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>
urlopen(), plus error handling and possible retries.

        err_env is a dict of additional info passed to the error handler