Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: utils/net.py

Issue 25549003: Fix running 'import run_isolated' at python interactive prompt. (Closed) Base URL: https://chromium.googlesource.com/a/chromium/tools/swarm_client@1_update_item
Patch Set: Added comment Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/swarming_test.py ('k') | utils/zip_package.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Classes and functions for generic network communication over HTTP.""" 5 """Classes and functions for generic network communication over HTTP."""
6 6
7 import cookielib 7 import cookielib
8 import cStringIO as StringIO 8 import cStringIO as StringIO
9 import httplib 9 import httplib
10 import itertools 10 import itertools
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 raise TimeoutError exception whenever there's no response from the server 312 raise TimeoutError exception whenever there's no response from the server
313 for more than |read_timeout| seconds. It can happen during any read 313 for more than |read_timeout| seconds. It can happen during any read
314 operation so once you pass non-None |read_timeout| be prepared to handle 314 operation so once you pass non-None |read_timeout| be prepared to handle
315 these exceptions in subsequent reads from the stream. 315 these exceptions in subsequent reads from the stream.
316 316
317 Returns a file-like object, where the response may be read from, or None 317 Returns a file-like object, where the response may be read from, or None
318 if it was unable to connect. If |stream| is False will read whole response 318 if it was unable to connect. If |stream| is False will read whole response
319 into memory buffer before returning file-like object that reads from this 319 into memory buffer before returning file-like object that reads from this
320 memory buffer. 320 memory buffer.
321 """ 321 """
322 assert urlpath and urlpath[0] == '/' 322 assert urlpath and urlpath[0] == '/', urlpath
323 323
324 if data is not None: 324 if data is not None:
325 assert method in (None, 'POST', 'PUT') 325 assert method in (None, 'POST', 'PUT')
326 method = method or 'POST' 326 method = method or 'POST'
327 content_type = content_type or DEFAULT_CONTENT_TYPE 327 content_type = content_type or DEFAULT_CONTENT_TYPE
328 body = self.encode_request_body(data, content_type) 328 body = self.encode_request_body(data, content_type)
329 else: 329 else:
330 assert method in (None, 'GET') 330 assert method in (None, 'GET')
331 method = method or 'GET' 331 method = method or 'GET'
332 body = None 332 body = None
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 attemp_obj = RetryAttempt(attempt, remaining) 765 attemp_obj = RetryAttempt(attempt, remaining)
766 yield attemp_obj 766 yield attemp_obj
767 if attemp_obj.skip_sleep: 767 if attemp_obj.skip_sleep:
768 continue 768 continue
769 # Only sleep if we are going to try again. 769 # Only sleep if we are going to try again.
770 if max_attempts and attempt != max_attempts - 1: 770 if max_attempts and attempt != max_attempts - 1:
771 remaining = (timeout - (current_time() - start)) if timeout else None 771 remaining = (timeout - (current_time() - start)) if timeout else None
772 if remaining is not None and remaining < 0: 772 if remaining is not None and remaining < 0:
773 break 773 break
774 sleep_before_retry(attempt, remaining) 774 sleep_before_retry(attempt, remaining)
OLDNEW
« no previous file with comments | « tests/swarming_test.py ('k') | utils/zip_package.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698