Tornado 6.5 Documentationnot thread-safe. The only method in Tornado that is safe to call from other threads is IOLoop.add_callback. You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread There are many styles of asynchronous interfaces: • Callback argument • Return a placeholder (Future, Promise, Deferred) • Deliver to a queue • Callback registry (e.g. POSIX signals) Regardless of which 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 coroutine returns its Future before the fetch is done0 码力 | 437 页 | 405.14 KB | 10 月前5
Coroutines and Structured Concurrency in PracticePractice ## DMITRY PROKOPTSEV ## Challenges when onboarding coroutines A lot of existing code mostly callback-based A custom-built I/O event loop predates Asio by a decade fine-tuned for specific use cases await_ready() const noexcept Performance optimization ## Awaitable example typedef void (*ares_addrinfo_callback)(void* arg, int status, int timeouts, struct ares_addrinfo* result); void ares_getaddrinfo(ares_channel_t* const char* name, const char* service, const struct ares_addrinfo_ hints* hints, ares_addrinfo_callback, void* arg); ## Awaitable example class DNSQuery { ares_channel_t* channel; const char*0 码力 | 103 页 | 1.98 MB | 1 年前3
Tornado 6.0 Documentation
not thread-safe. The only method in Tornado that is safe to call from other threads is IOLoop.add_callback. You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread There are many styles of asynchronous interfaces: • Callback argument • Return a placeholder (Future, Promise, Deferred) • Deliver to a queue • Callback registry (e.g. POSIX signals) Regardless of which def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the coroutine returns its Future before the fetch0 码力 | 869 页 | 692.83 KB | 2 年前3
Tornado 5.1 Documentation
not thread-safe. The only method in Tornado that is safe to call from other threads is IOLoop.add_callback. You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread There are many styles of asynchronous interfaces: • Callback argument • Return a placeholder (Future, Promise, Deferred) • Deliver to a queue • Callback registry (e.g. POSIX signals) Regardless of which def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the coroutine returns its Future before the fetch0 码力 | 243 页 | 895.80 KB | 2 年前3
Tornado 5.1 Documentation
not thread-safe. The only method in Tornado that is safe to call from other threads is IOLoop.add_callback. You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread There are many styles of asynchronous interfaces: • Callback argument • Return a placeholder (Future, Promise, Deferred) • Deliver to a queue • Callback registry (e.g. POSIX signals) Regardless of which def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the coroutine returns its Future before the fetch0 码力 | 359 页 | 347.32 KB | 2 年前3
Tornado 4.5 Documentation
There are many styles of asynchronous interfaces: • Callback argument • Return a placeholder (Future, Promise, Deferred) • Deliver to a queue • Callback registry (e.g. POSIX signals) Regardless of which asynchronous with a callback argument: from tornado.httpclient importAsyncHTTPClient def asynchronous_fetch(url, callback): http_client =AsyncHTTPClient() def handle_response(response): callback(response callback(response.body) http_client.fetch(url, callback=handle_response) And again with a Future instead of a callback: from tornado.concurrent import Future def async_fetch_future(url): http_client =AsyncHTTPClient()0 码力 | 222 页 | 833.04 KB | 2 年前3
Tornado 4.5 Documentation
There are many styles of asynchronous interfaces: • Callback argument • Return a placeholder (Future, Promise, Deferred) • Deliver to a queue • Callback registry (e.g. POSIX signals) Regardless of which with a callback argument: from tornado.httpclient importAsyncHTTPClient def asynchronous_fetch(url, callback): http_client =AsyncHTTPClient() def handle_response(response): callback(response callback(response.body) http_client.fetch(url, callback=handle_response) And again with a Future instead of a callback: from tornado.concurrent import Future def async_fetch_future(url): http_client0 码力 | 333 页 | 322.34 KB | 2 年前3
Tornado 6.1 Documentation
not thread-safe. The only method in Tornado that is safe to call from other threads is IOLoop.add_callback. You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread There are many styles of asynchronous interfaces: • Callback argument • Return a placeholder (Future, Promise, Deferred) • Deliver to a queue • Callback registry (e.g. POSIX signals) Regardless of which 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 coroutine returns its Future before the fetch is done0 码力 | 931 页 | 708.03 KB | 2 年前3
Tornado 6.2 Documentation
not thread-safe. The only method in Tornado that is safe to call from other threads is IOLoop.add_callback. You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread There are many styles of asynchronous interfaces: • Callback argument • Return a placeholder (Future, Promise, Deferred) • Deliver to a queue • Callback registry (e.g. POSIX signals) Regardless of which def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the coroutine returns its Future before the fetch0 码力 | 260 页 | 1.06 MB | 2 年前3
Tornado 6.1 Documentation
not thread-safe. The only method in Tornado that is safe to call from other threads is IOLoop.add_callback. You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread There are many styles of asynchronous interfaces: • Callback argument • Return a placeholder (Future, Promise, Deferred) • Deliver to a queue • Callback registry (e.g. POSIX signals) Regardless of which def on_fetch(f): my_future.set_result(f.result().body) fetch_future.add_done_callback(on_fetch) return my_future Notice that the coroutine returns its Future before the fetch0 码力 | 245 页 | 904.24 KB | 2 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100
相关搜索词
IOLoopDeprecationCallbackType AnnotationPython Compatibilitycoroutinesstructured concurrencycallback-basedI/O event loopobject lifetime managementTornado 6.0APIsDeprecationWarningPython 3.5.2native coroutinesTornado框架异步网络库HTTP服务器Web框架协程库版本5.1弃用接口Python版本支持模块更新Tornado长连接协程tornado.webtornado.httpservertornado.iostreamtornado.concurrenttornado.websocketasynchronous networkingevent loopIOStreamcoroutineWebSocket协议WSGI支持Python Web FrameworkAsynchronous NetworkingHTTP ServerCoroutine Library













