Python httplib.REQUEST_TIMEOUT Examples
The following are 12
code examples of httplib.REQUEST_TIMEOUT().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
httplib
, or try the search function
.
Example #1
Source File: playground.py From cloud-playground with Apache License 2.0 | 6 votes |
def post(self): # pylint:disable-msg=invalid-name """Handles HTTP POST requests.""" repo_url = self.request.data.get('repo_url') if not repo_url: Abort(httplib.BAD_REQUEST, 'repo_url required') repo = model.GetRepo(repo_url) if not repo: html_url = name = description = repo_url repo = model.CreateRepoAsync(owner=model.GetManualTemplateOwner(), repo_url=repo_url, html_url=html_url, name=name, description=description, show_files=[], read_only_files=[], read_only_demo_url=None) template_project = repo.project.get() if not template_project or template_project.in_progress_task_name: Abort(httplib.REQUEST_TIMEOUT, 'Sorry. Requested template is not yet available. ' 'Please try again in 30 seconds.') expiration_seconds = self.request.data.get('expiration_seconds') project = model.CopyProject(self.user, template_project, expiration_seconds, new_project_name=template_project.project_name) return self.DictOfProject(project)
Example #2
Source File: playground.py From cloud-playground with Apache License 2.0 | 6 votes |
def post(self): # pylint:disable-msg=invalid-name """Handles HTTP POST requests.""" repo_url = self.request.data.get('repo_url') if not repo_url: Abort(httplib.BAD_REQUEST, 'repo_url required') repo = model.GetRepo(repo_url) if not repo: html_url = name = description = repo_url repo = model.CreateRepoAsync(owner=model.GetManualTemplateOwner(), repo_url=repo_url, html_url=html_url, name=name, description=description, show_files=[], read_only_files=[], read_only_demo_url=None) project = repo.project.get() if not project or project.in_progress_task_name: Abort(httplib.REQUEST_TIMEOUT, 'Sorry. Requested template is not yet available. ' 'Please try again in 30 seconds.') return self.DictOfProject(project)
Example #3
Source File: api_utils.py From billing-export-python with Apache License 2.0 | 5 votes |
def _should_retry(resp): """Given a urlfetch response, decide whether to retry that request.""" return (resp.status_code == httplib.REQUEST_TIMEOUT or (resp.status_code >= 500 and resp.status_code < 600))
Example #4
Source File: api_utils.py From MyLife with MIT License | 5 votes |
def _should_retry(resp): """Given a urlfetch response, decide whether to retry that request.""" return (resp.status_code == httplib.REQUEST_TIMEOUT or (resp.status_code >= 500 and resp.status_code < 600))
Example #5
Source File: api_utils.py From luci-py with Apache License 2.0 | 5 votes |
def _should_retry(resp): """Given a urlfetch response, decide whether to retry that request.""" return (resp.status_code == httplib.REQUEST_TIMEOUT or (resp.status_code >= 500 and resp.status_code < 600))
Example #6
Source File: api_utils.py From luci-py with Apache License 2.0 | 5 votes |
def _should_retry(resp): """Given a urlfetch response, decide whether to retry that request.""" return (resp.status_code == httplib.REQUEST_TIMEOUT or (resp.status_code >= 500 and resp.status_code < 600))
Example #7
Source File: http_agent.py From citest with Apache License 2.0 | 5 votes |
def timed_out(self): return self.__http_response.http_code in [httplib.REQUEST_TIMEOUT, httplib.GATEWAY_TIMEOUT]
Example #8
Source File: playground.py From cloud-playground with Apache License 2.0 | 5 votes |
def post(self): # pylint:disable-msg=invalid-name """Handles HTTP POST requests.""" tp = self.request.environ['playground.project'] if not tp or tp.in_progress_task_name: Abort(httplib.REQUEST_TIMEOUT, 'Sorry. Requested template is not yet available. ' 'Please try again in 30 seconds.') expiration_seconds = self.request.data.get('expiration_seconds') project = model.CopyProject(self.user, tp, expiration_seconds) return self.DictOfProject(project)
Example #9
Source File: errors.py From billing-export-python with Apache License 2.0 | 4 votes |
def check_status(status, expected, path, headers=None, resp_headers=None, extras=None): """Check HTTP response status is expected. Args: status: HTTP response status. int. expected: a list of expected statuses. A list of ints. path: filename or a path prefix. headers: HTTP request headers. resp_headers: HTTP response headers. extras: extra info to be logged verbatim if error occurs. Raises: AuthorizationError: if authorization failed. NotFoundError: if an object that's expected to exist doesn't. TimeoutError: if HTTP request timed out. ServerError: if server experienced some errors. FatalError: if any other unexpected errors occurred. """ if status in expected: return msg = ('Expect status %r from Google Storage. But got status %d.\n' 'Path: %r.\n' 'Request headers: %r.\n' 'Response headers: %r.\n' 'Extra info: %r.\n' % (expected, status, path, headers, resp_headers, extras)) if status == httplib.UNAUTHORIZED: raise AuthorizationError(msg) elif status == httplib.FORBIDDEN: raise ForbiddenError(msg) elif status == httplib.NOT_FOUND: raise NotFoundError(msg) elif status == httplib.REQUEST_TIMEOUT: raise TimeoutError(msg) elif status == httplib.REQUESTED_RANGE_NOT_SATISFIABLE: raise InvalidRange(msg) elif status >= 500: raise ServerError(msg) else: raise FatalError(msg)
Example #10
Source File: errors.py From MyLife with MIT License | 4 votes |
def check_status(status, expected, path, headers=None, resp_headers=None, body=None, extras=None): """Check HTTP response status is expected. Args: status: HTTP response status. int. expected: a list of expected statuses. A list of ints. path: filename or a path prefix. headers: HTTP request headers. resp_headers: HTTP response headers. body: HTTP response body. extras: extra info to be logged verbatim if error occurs. Raises: AuthorizationError: if authorization failed. NotFoundError: if an object that's expected to exist doesn't. TimeoutError: if HTTP request timed out. ServerError: if server experienced some errors. FatalError: if any other unexpected errors occurred. """ if status in expected: return msg = ('Expect status %r from Google Storage. But got status %d.\n' 'Path: %r.\n' 'Request headers: %r.\n' 'Response headers: %r.\n' 'Body: %r.\n' 'Extra info: %r.\n' % (expected, status, path, headers, resp_headers, body, extras)) if status == httplib.UNAUTHORIZED: raise AuthorizationError(msg) elif status == httplib.FORBIDDEN: raise ForbiddenError(msg) elif status == httplib.NOT_FOUND: raise NotFoundError(msg) elif status == httplib.REQUEST_TIMEOUT: raise TimeoutError(msg) elif status == httplib.REQUESTED_RANGE_NOT_SATISFIABLE: raise InvalidRange(msg) elif (status == httplib.OK and 308 in expected and httplib.OK not in expected): raise FileClosedError(msg) elif status >= 500: raise ServerError(msg) else: raise FatalError(msg)
Example #11
Source File: errors.py From luci-py with Apache License 2.0 | 4 votes |
def check_status(status, expected, path, headers=None, resp_headers=None, body=None, extras=None): """Check HTTP response status is expected. Args: status: HTTP response status. int. expected: a list of expected statuses. A list of ints. path: filename or a path prefix. headers: HTTP request headers. resp_headers: HTTP response headers. body: HTTP response body. extras: extra info to be logged verbatim if error occurs. Raises: AuthorizationError: if authorization failed. NotFoundError: if an object that's expected to exist doesn't. TimeoutError: if HTTP request timed out. ServerError: if server experienced some errors. FatalError: if any other unexpected errors occurred. """ if status in expected: return msg = ('Expect status %r from Google Storage. But got status %d.\n' 'Path: %r.\n' 'Request headers: %r.\n' 'Response headers: %r.\n' 'Body: %r.\n' 'Extra info: %r.\n' % (expected, status, path, headers, resp_headers, body, extras)) if status == httplib.UNAUTHORIZED: raise AuthorizationError(msg) elif status == httplib.FORBIDDEN: raise ForbiddenError(msg) elif status == httplib.NOT_FOUND: raise NotFoundError(msg) elif status == httplib.REQUEST_TIMEOUT: raise TimeoutError(msg) elif status == httplib.REQUESTED_RANGE_NOT_SATISFIABLE: raise InvalidRange(msg) elif (status == httplib.OK and 308 in expected and httplib.OK not in expected): raise FileClosedError(msg) elif status >= 500: raise ServerError(msg) else: raise FatalError(msg)
Example #12
Source File: errors.py From luci-py with Apache License 2.0 | 4 votes |
def check_status(status, expected, path, headers=None, resp_headers=None, body=None, extras=None): """Check HTTP response status is expected. Args: status: HTTP response status. int. expected: a list of expected statuses. A list of ints. path: filename or a path prefix. headers: HTTP request headers. resp_headers: HTTP response headers. body: HTTP response body. extras: extra info to be logged verbatim if error occurs. Raises: AuthorizationError: if authorization failed. NotFoundError: if an object that's expected to exist doesn't. TimeoutError: if HTTP request timed out. ServerError: if server experienced some errors. FatalError: if any other unexpected errors occurred. """ if status in expected: return msg = ('Expect status %r from Google Storage. But got status %d.\n' 'Path: %r.\n' 'Request headers: %r.\n' 'Response headers: %r.\n' 'Body: %r.\n' 'Extra info: %r.\n' % (expected, status, path, headers, resp_headers, body, extras)) if status == httplib.UNAUTHORIZED: raise AuthorizationError(msg) elif status == httplib.FORBIDDEN: raise ForbiddenError(msg) elif status == httplib.NOT_FOUND: raise NotFoundError(msg) elif status == httplib.REQUEST_TIMEOUT: raise TimeoutError(msg) elif status == httplib.REQUESTED_RANGE_NOT_SATISFIABLE: raise InvalidRange(msg) elif (status == httplib.OK and 308 in expected and httplib.OK not in expected): raise FileClosedError(msg) elif status >= 500: raise ServerError(msg) else: raise FatalError(msg)