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.