python

An introduction to the multiprocessing module

    Multi-threading in python cannot take advantage of multi-core. If you want to fully use the resources of multi-core CPU (os.cpu_count() view), you need to use multi-process in most cases in python. Python provides multiprocessing.

The point that print(os.cpu_count()) 
needs to be emphasized again is that unlike threads, processes do not have any shared state, and the data modified by a process is limited to changes within the process.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324808259&siteId=291194637