| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import logging | |
| 6 from google.appengine.api import urlfetch | 5 from google.appengine.api import urlfetch |
| 7 | 6 |
| 8 from future import Future | 7 from future import Future |
| 9 | 8 |
| 10 class _AsyncFetchDelegate(object): | 9 class _AsyncFetchDelegate(object): |
| 11 def __init__(self, rpc): | 10 def __init__(self, rpc): |
| 12 self._rpc = rpc | 11 self._rpc = rpc |
| 13 | 12 |
| 14 def Get(self): | 13 def Get(self): |
| 15 self._rpc.wait() | 14 self._rpc.wait() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 26 """Fetches a file synchronously. | 25 """Fetches a file synchronously. |
| 27 """ | 26 """ |
| 28 return urlfetch.fetch(self._base_path + '/' + url) | 27 return urlfetch.fetch(self._base_path + '/' + url) |
| 29 | 28 |
| 30 def FetchAsync(self, url): | 29 def FetchAsync(self, url): |
| 31 """Fetches a file asynchronously, and returns a Future with the result. | 30 """Fetches a file asynchronously, and returns a Future with the result. |
| 32 """ | 31 """ |
| 33 rpc = urlfetch.create_rpc() | 32 rpc = urlfetch.create_rpc() |
| 34 urlfetch.make_fetch_call(rpc, self._base_path + '/' + url) | 33 urlfetch.make_fetch_call(rpc, self._base_path + '/' + url) |
| 35 return Future(delegate=_AsyncFetchDelegate(rpc)) | 34 return Future(delegate=_AsyncFetchDelegate(rpc)) |
| OLD | NEW |