Python open source Asynchronous concurrency framework

Source: Internet
Author: User

The future of the Python open source asynchronous concurrency framework "open source technology conference" hosted by CSDN, the world's largest Chinese it community, March 30, 2014 the"(Open Source technology Conference the, referred to as OSTC the) was held at Li Ting Hua Yuan hotel in Beijing. With the theme of "open mind, open source", the Conference invited more than 30 open source industry veterans from across the country to deliver keynote speeches and dozens of open source community participation, with over 500 open source software developers, contributors and open source enthusiasts. As a "ground gas" open-source event, "OSTC the"With its openness, professionalism, social and well received by the participants." Wang Chuan: My name is Wang Chuan, the English name is Fantix, my work mainly uses the Python to do the business, the amateur time also will study the different open source project, today mainly and Python has the relation, Python3.4 two weeks ago released a new version, there is today's new library, I believe you have a good understanding of Python, or more familiar, simple to say that Python is interpreted, more like scripting language, first from the two more easily confused concept began to talk about, do not know if you have to do passport experience , I have a period of time to do a Hong Kong and Macao Pass, 10 o'clock in the morning go, 2:30 P.M. to finish, lunch is not eaten, really not inefficient, people are too many, from the window has been lined to the door, do this card so slow, we certainly do not want to, the leader thought a rut, open a window, open 10 windows, The volume of the mouth to go up, this photo is very realistic, and my photo scene is not bad, although this photo was taken during the Spring Festival. The concept of parallelism comes out, parallel is about multiple processors, multiple windows together to handle the business of the pass, to say that this is just row a team, spend 4.5 hours, the scene I lined up three teams, first line to take the number, and then line up photography, photography can handle passes, each team is people in line, concurrency concept also came out,    How many people can stand in the hall, can stand 800 people, this concurrency is 800. Parallel is more concerned with the window or the processing side, there must be a processor, its concept is to multiple processors, at the same time in dealing with different things, and the relative not concerned about the processing of the party, more attention is the user, we have a large number of users at the same time access to a black box server, while the number of access is concurrent, Concurrency does not concern the server in the end there is (EK) CPU, or look CPU, if there is a problem, if only one CPU concurrency how can be implemented?    There is a common practice is to put concurrent to the operating system, with the operating system of multi-process or multi-threaded to achieve concurrency, multi-process is not discussed here, because Python has some il multithreading is actually not ideal, so there is a new scenario. Comparison of a conventional approach with the operating system provided by these interfaces, often used to do concurrency, through these interfaces are easy to operate multiple IL metering, to achieve pilot-driven concurrent programming, what kind of pilot drive it? Now there is a phenomenon need to serve 100,000 clients at the same time, 100,000 connections first created, through such a loop to achieve concurrency, select from the 100,000 client here to select the first client with data, and then do the following things, the following RECIV can be implemented in a non-group way, Can be very fast to complete the process, if the select False intelligence to give a wrong information, do nothing, followingCycle, once this cycle runs, the concurrency is realized. This kind of code simple write example also can, if write big external application is very troublesome, so use the framework, Python about asynchronous concurrency framework application many, such as tornado This is Facebook's open-source asynchronous framework, put sock to tornado IL look, Or the main loop can be implemented socket, such as a new connection, new data, there is time to call this callback function, this callback function is asynchronous write the way, but write more is also a certain difficulty, other libraries have to the bottom of the package, such as a veteran of the cool is twisted, The Sub-Assembly is protocol and TRANSBO (sound), protocol to the application layer of the Protocol to do the reload, Transbo (sound) to the bottom of the transmission to do encapsulation, when the need for data to call (Trsbook RIT) can send this data, To have a well-known deferred, the realization of the separation of data sources and functions, defebrred is a relatively well-known part of the code written with it and Copak, write small can, write large very difficult to find clear a program before and after the order, so throw away deferred, with a new technology, In (English), such as callbocks, can be directly in the same function to get the client, the following program has 4 to 5 callback functions, written in the same function like synchronous, is the asynchronous way of writing, convenient for programmers to write maintenance, show the asynchronous switch, relative to the pursuit of the ultimate programmer,    The introduction of the conversion, evntlet,gevent, can be the code of the formation of subsidies, if the call to regular code like Oropen, if there are some existing code, is synchronous, such as Jangl if a concurrency to achieve is one of the few choices.    For a toggle between display and implicit, implicit hiding is deeper.    For Python3 support for tornado implementation, gevent I do, the last batch has been sent to the author.    From the statistics, gevent is not very active. Interoperability, most of the framework today to achieve the support of twisted, time is longer, everyone will have legacy code, become the de facto standard, but for the different framework of the third-party class library support, these frameworks are each faction, each person's interface will have a set of their own implementation,    Like twisted or MySQL, what's going to happen in the future? Python author, wrote a library is a new write a library of programming, Python author and twisted author chat too much, in fact, this library is quite like twisted, such as Collback and import is the same, add two seconds after the callback, the processThe sequence outputs one (lawork) in not two seconds.    Protocol transport sent back when he received the message.    The future concept is used to encapsulate the callback function, which is the interface that exists in the TES library.    Asyncio,from can be threaded together, corouitine for asynchronous functions, micro-threading, Ctrip, Output Hello World, modified corouitine.    At the bottom there is a task and a future with a result that is thrown to the main loop to achieve such a result. Asyncio More is a specification, with 3.4 released is the reference implementation, that is, the blue box, as well as the original engine, this is their own event loop, write their own application, Asyncio more fully consider interoperability, you can replace the original, change on their own,    Or there are two kinds of engines in Asyncio,asyncio, by using different adapters, with different codes, with twisted code, with gevent code.  In addition, using the assembled engine, with the Asyncio basic frame, use the core of the existing library, for example with twistedEventLopp, you can directly implement the code is the same as the bottom. Future interoperability, and to the existing adaptation significance is not very large, because asyncio each framework as long as the implementation of their own adaptation to the standard above, all the code can be implemented through this network interoperability, this is very good in the program, I hope to achieve, now this implementation process is already done, Like twisted and tomado already in the realization has done, I myself in do gevnt adaptation, is so thank everybody!

Python open source Asynchronous concurrency framework

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.