January 2019
Beginner to intermediate
776 pages
19h 58m
English
We will build an asynchronous application to illustrate the functionality of Tornado. In this example, AsyncHttpClient of Tornado has been used.
Listing 4.12 explains the code for a simple network application using Tornado:
#!/usr/bin/env python # Python Network Programming Cookbook, Second Edition -- Chapter - 3 # This program is optimized for Python 2.7.12 and Python 3.5.2. # It may run on any other version with/without modifications. import argparse import tornado.ioloop import tornado.httpclient class TornadoAsync(): def handle_request(self,response): if response.error: print ("Error:", response.error) else: print (response.body) tornado.ioloop.IOLoop.instance().stop() def run_server(url): tornadoAsync = TornadoAsync() ...Read now
Unlock full access