Python--dummy_thread (_dummy_thread in Python 3.+)

Source: Internet
Author: User

  The dummy_thread module is called the _dummy_thread module in Python 3, and the Python 2to3 tool can help you automatically change the name of the module in the old code. However, it is more recommended to use a high-level dummy_threading module than this module.

As with the dummy_thread module, the Python 3 is called _dummy_threading,and thedummy_threading is the same interface as the threading module, designed for those that do not support The function of the threading module is provided on the platform of the thread module .

Python 2.7 dummy_thread module source code;

Python 2.7 dummy_threading module source code;

The interface of the module is the same as the thread module (renamed _thread module in Python 3), and the meaning of this module is that it provides the functionality of the thread module on a platform that does not implement the thread module.

Recommended usage

 Dummy_thread

Try:    import thread as _threadexcept importerror:    import Dummy_thread as _thread

Dummy_threading

Try:    import threading as _threadingexcept importerror:    import dummy_threading as _threading

Be careful to avoid a thread that is being created to use these two modules because it waits for another thread that has not yet been created and thus causes a deadlock, which is more than blocking I/O.

Python--dummy_thread (_dummy_thread in Python 3.+)

Related Article

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.