Tornado 6.0 Documentation
AsyncHTTPClient() my_future = Future() fetch_future = http_client.fetch(url) def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice returns when the next yield is reached future = self.gen.send(self.next) def callback(f): self.next = f.result() self.run() future.add_done_callback(callback) The decorator receives tornado.httpclient.AsyncHTTPClient[source] An non-blocking HTTP client. Example usage: async def f(): http_client = AsyncHTTPClient() try: response = await http_client.fetch("http://www0 码力 | 869 页 | 692.83 KB | 1 年前3Tornado 6.1 Documentation
AsyncHTTPClient() my_future = Future() fetch_future = http_client.fetch(url) def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice returns when the next yield is reached future = self.gen.send(self.next) def callback(f): self.next = f.result() self.run() future.add_done_callback(callback) The decorator receives tornado.httpclient.AsyncHTTPClient[source] An non-blocking HTTP client. Example usage: async def f(): http_client = AsyncHTTPClient() try: response = await http_client.fetch("http://www0 码力 | 931 页 | 708.03 KB | 1 年前3Tornado 4.5 Documentation
fetch_future = http_client.fetch(url) fetch_future.add_done_callback( lambda f: my_future.set_result(f.result())) return my_future The raw Future version is more complex, but Futures are convert_yielded to convert anything that would work with yield into a form that will work with await: async def f(): executor = concurrent.futures.ThreadPoolExecutor() await tornado.gen.convert_yielded(executor returns when the next yield is reached future = self.gen.send(self.next) def callback(f): self.next = f.result() self.run() future.add_done_callback(callback) The decorator receives0 码力 | 333 页 | 322.34 KB | 1 年前3Tornado 4.5 Documentation
Future() fetch_future = http_client.fetch(url) fetch_future.add_done_callback( lambda f: my_future.set_result(f.result())) return my_future The raw Future version is more complex, but Futures are nonetheless convert_yielded to convert anything that would work with yield into a form that will work with await: async def f(): executor = concurrent.futures.ThreadPoolExecutor() await tornado.gen.convert_yielded(executor.submit(g)) # It returns when the next yield is reached future = self.gen.send(self.next) def callback(f): self.next = f.result() self.run() future.add_done_callback(callback) 12 Chapter 4. Documentation Tornado0 码力 | 222 页 | 833.04 KB | 1 年前3Tornado 5.1 Documentation
AsyncHTTPClient() my_future = Future() fetch_future = http_client.fetch(url) def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the # It returns when the next yield is reached future = self.gen.send(self.next) def callback(f): self.next = f.result() self.run() future.add_done_callback(callback) The decorator receives a Future from class tornado.httpclient.AsyncHTTPClient An non-blocking HTTP client. Example usage: async def f(): http_client = AsyncHTTPClient() try: response = await http_client.fetch("http://www.google.com")0 码力 | 243 页 | 895.80 KB | 1 年前3Tornado 5.1 Documentation
AsyncHTTPClient() my_future = Future() fetch_future = http_client.fetch(url) def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice returns when the next yield is reached future = self.gen.send(self.next) def callback(f): self.next = f.result() self.run() future.add_done_callback(callback) The decorator receives class tornado.httpclient.AsyncHTTPClient An non-blocking HTTP client. Example usage: async def f(): http_client = AsyncHTTPClient() try: response = await http_client.fetch("http://www0 码力 | 359 页 | 347.32 KB | 1 年前3Tornado 6.5 Documentation
AsyncHTTPClient() my_future = Future() fetch_future = http_client.fetch(url) def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the # It returns when the next yield is reached future = self.gen.send(self.next) def callback(f): self.next = f.result() self.run() future.add_done_callback(callback) The decorator receives a Future from async for url in q: if url is None: return try: await fetch_url(url) except Exception as e: print(f"Exception: {e} {url}") dead.add(url) finally: q.task_done() await q.put(base_url) # Start workers0 码力 | 272 页 | 1.12 MB | 2 月前3Tornado 6.1 Documentation
AsyncHTTPClient() my_future = Future() fetch_future = http_client.fetch(url) def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the # It returns when the next yield is reached future = self.gen.send(self.next) def callback(f): self.next = f.result() self.run() future.add_done_callback(callback) The decorator receives a Future from class tornado.httpclient.AsyncHTTPClient An non-blocking HTTP client. Example usage: async def f(): http_client = AsyncHTTPClient() try: response = await http_client.fetch("http://www.google.com")0 码力 | 245 页 | 904.24 KB | 1 年前3Tornado 6.0 Documentation
AsyncHTTPClient() my_future = Future() fetch_future = http_client.fetch(url) def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the # It returns when the next yield is reached future = self.gen.send(self.next) def callback(f): self.next = f.result() self.run() future.add_done_callback(callback) The decorator receives a Future from class tornado.httpclient.AsyncHTTPClient An non-blocking HTTP client. Example usage: async def f(): http_client = AsyncHTTPClient() try: response = await http_client.fetch("http://www.google.com")0 码力 | 245 页 | 885.76 KB | 1 年前3Tornado 6.4 Documentation
AsyncHTTPClient() my_future = Future() fetch_future = http_client.fetch(url) def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the # It returns when the next yield is reached future = self.gen.send(self.next) def callback(f): self.next = f.result() self.run() future.add_done_callback(callback) The decorator receives a Future from If plus is true (the default), spaces will be represented as + and slashes will be represented as %2F. This is appropriate for query strings. If plus is false, spaces will be represented as %20 and slashes0 码力 | 268 页 | 1.09 MB | 1 年前3
共 20 条
- 1
- 2