Python Multi-process

Source: Internet
Author: User

Python Multi-process

Because the Gil exists in Python, so the performance of multithreading is not good, so you want to fully use the multi-core CPU resources, you can use multi-process.

1.Process class

The process class is used to create the

Class multiprocessing. Process (Group=none, Target=none, Name=none, args= (), kwargs={}, *, Daemon=none)

Where group should always be empty, its existence is only with threading. Thread compatible, Threading,thread also has a group parameter, but now it is not used, reserved until later thread groups implemented later.

Target, a callable object that passes in a function that executes when the Run method is executed.

Name is the name that defines the process, and if this parameter is not defined, the default name is Process-x (x is the ordinal).

Args is a parameter tuple, and Kwargs is a dictionary that is passed to target as a parameter.

Parameter daemon can set whether the process is a daemon, and if it is empty, this parameter will inherit from the parent process.

Python Multi-process

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.