Tornado 6.5 DocumentationThe following optional packages may be useful: • pycurl is used by the optional tornado.curl_httpclient. Libcurl version 7.22 or higher is required. • pycares is an alternative non-blocking DNS resolver Examples Here is a sample synchronous function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) return response.body And And here is the same function rewritten asynchronously as a native coroutine: from tornado.httpclient import AsyncHTTPClient async def asynchronous_fetch(url): http_client = AsyncHTTPClient() response0 码力 | 272 页 | 1.12 MB | 3 月前3
Tornado 6.5 Documentationoptional packages may be useful:pycurl [http://pycurl.io/] is used by the optional tornado.curl_httpclient. Libcurl version 7.22 or higher is required. pycares [https://pypi.org/project/pycares/] is an to the browser HTTP servers and clients tornado.httpserver — Non-blocking HTTP server tornado.httpclient — Asynchronous HTTP client tornado.httputil — Manipulate HTTP headers and URLs tornado.http1connection Examples Here is a sample synchronous function: from tornado.httpclient import HTTPClient def synchronous_fetch(url): http_client = HTTPClient() response = http_client.fetch(url) return response0 码力 | 437 页 | 405.14 KB | 3 月前3
Python 标准库参考指南 2.7.18 that uses the dispatcher class to implement its socket handling: import asyncore, socket class HTTPClient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) self def handle_write(self): sent = self.send(self.buffer) self.buffer = self.buffer[sent:] client = HTTPClient('www.python.org', '/') asyncore.loop() 17.6.2 asyncore Example basic echo server Here is a basic0 码力 | 1552 页 | 7.42 MB | 10 月前3
Python 标准库参考指南 2.7.18 that uses the dispatcher class to implement its socket handling: import asyncore, socket class HTTPClient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) self def handle_write(self): sent = self.send(self.buffer) self.buffer = self.buffer[sent:] client = HTTPClient('www.python.org', '/') asyncore.loop() 17.6.2 asyncore Example basic echo server Here is a basic0 码力 | 1552 页 | 7.42 MB | 10 月前3
Python 标准库参考指南 2.7.18 that uses the dispatcher class to implement its socket handling: import asyncore, socket class HTTPClient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) self def handle_write(self): sent = self.send(self.buffer) self.buffer = self.buffer[sent:] client = HTTPClient('www.python.org', '/') asyncore.loop() 17.6.2 asyncore Example basic echo server Here is a basic0 码力 | 1552 页 | 7.42 MB | 10 月前3
Python 标准库参考指南 3.6.15 1 asyncore 示例基本 HTTP 客户端 下面是一个非常基本的 HTTP 客户端,它使用了dispatcher 类来实现套接字处理: import asyncore class HTTPClient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) self def handle_write(self): sent = self.send(self.buffer) self.buffer = self.buffer[sent:] client = HTTPClient('www.python.org', '/') asyncore.loop() 900 Chapter 18. Interprocess Communication and Networking0 码力 | 1886 页 | 8.95 MB | 10 月前3
Python 标准库参考指南 3.6.15 1 asyncore 示例基本 HTTP 客户端 下面是一个非常基本的 HTTP 客户端,它使用了dispatcher 类来实现套接字处理: import asyncore class HTTPClient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) self def handle_write(self): sent = self.send(self.buffer) self.buffer = self.buffer[sent:] client = HTTPClient('www.python.org', '/') asyncore.loop() 900 Chapter 18. Interprocess Communication and Networking0 码力 | 1886 页 | 8.95 MB | 10 月前3
Python 标准库参考指南 3.7.13 1 asyncore 示例基本 HTTP 客户端 下面是一个非常基本的 HTTP 客户端,它使用了dispatcher 类来实现套接字处理: import asyncore class HTTPClient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) self def handle_write(self): sent = self.send(self.buffer) self.buffer = self.buffer[sent:] client = HTTPClient('www.python.org', '/') asyncore.loop() 892 Chapter 19. 网络和进程间通信 The Python Library Reference0 码力 | 1846 页 | 9.09 MB | 10 月前3
Python 标准库参考指南 3.7.13 1 asyncore 示例基本 HTTP 客户端 下面是一个非常基本的 HTTP 客户端,它使用了dispatcher 类来实现套接字处理: import asyncore class HTTPClient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) self def handle_write(self): sent = self.send(self.buffer) self.buffer = self.buffer[sent:] client = HTTPClient('www.python.org', '/') asyncore.loop() 19.6.2 asyncore 示例基本回显服务器 下面是一个基本的回显服务器,它使用了dispatcher0 码力 | 1961 页 | 9.14 MB | 10 月前3
Python 标准库参考指南 3.8.20 1 asyncore 示例基本 HTTP 客户端 下面是一个非常基本的 HTTP 客户端,它使用了dispatcher 类来实现套接字处理: import asyncore class HTTPClient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) self def handle_write(self): sent = self.send(self.buffer) self.buffer = self.buffer[sent:] client = HTTPClient('www.python.org', '/') asyncore.loop() 18.6. asyncore --- 异步套接字处理器 937 The Python Library Reference0 码力 | 1927 页 | 9.69 MB | 10 月前3
共 26 条
- 1
- 2
- 3













