Configure Python + tornado and pythontornado in Windows

Source: Internet
Author: User

Configure Python + tornado and pythontornado in Windows

1. Install Python 2.7.x

Address: https://www.python.org/downloads/release/python-278/

2. Install python setuptools

Address: https://pypi.python.org/pypi/setuptools

3, (skip this step)

My computer-> properties-> set system variables, and then you can directly use python and easy_install in cmd.

Add the python installation Path and the scripts Path under the Path variable of the environment variable.

 


 

 

 

4. Open cmd and enter easy_install tornado.

The latest tornado version is automatically found and installed.


If you skip step 3, open the corresponding Python installation path and enter easy_install tornado.

 

 

 




Python tornado performs a large number of SQL write operations and causes all other blocking operations. Is there a problem with my method or is it true?

Tornado is a single-process, single-thread server. If it is a synchronous request, a long request does not end and cannot process other requests. However, tornado supports asynchronous requests, that is, when we are waiting for the results, we will not block it. We will add a callback function as the parameter and notify you through the callback function when there is a result. In this way, the server can accept other requests.

For php, you can check the configuration file of php-fpm, which is used by multiple processes to handle requests.

How to Understand python tornado

Def pagecache (key = "", time = PAGE_CACHE_TIME, key_suffix_calc_func = None): def _ decorate (method): def _ wrapper (* args, ** kwargs): if not MC_Available: method (* args, ** kwargs) return req = args [0] key_with_suffix = key if required: key_suffix = key_suffix_calc_func (* args, ** kwargs) if key_suffix: key_with_suffix = '% s: % s' % (key, quoted_string (key_suffix) if key_with_suffix: key_with_suffix = Str (key_with_suffix) else: key_with_suffix = req. request. path mc = pylibmc. client () html = mc. get (key_with_suffix) request_time = int (req. request. request time () * 1000) if html: req. write (html) # req. write (RQT_RE.sub ('<span id = "requesttime"> % d </span>' % request_time, html) else: result = method (* args, ** kwargs) mc. set (key_with_suffix, result, time) return _ wrapper return _ decorate is Python Decorator Function, which has little to do with tornado. You can understand it by learning Python Decorator.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.