Parallel processing of multiple tasks. In order to prevent blocking, we plan to use threads for processing, but the results are not satisfactory after actual tests (of course, it must be related to my familiarity with threads ), multiple processes are stable and reliable :)
PS: chrome opens a process for each tab to ensure security and stability.
I often see some comments on the Internet, such
In an early article on IBM developerworks, I demonstrated a simple and effective mode for implementing Linear Programming Using python. However, one drawback of this method is that it does not always improve the application.ProgramBecause the global interpreter lock (Gil) effectively limits the thread to one core. If you need to use all the cores in the computer, you usually need to use the fork operation to increase the speed.
From: http://www.ibm.com/developerworks/cn/aix/library/au-multiprocessing/
Due to the controversial Gil mechanism in Python, threads become a weakness of Python (compared with C/C ++ and Java ).
Additional reading: thread security and Gil in Python
In addition, it is said that in Linux, due to the kernel mechanism, the thread does not seem to be widely used by the process.
For the same task, in order to make full use of the CPU to increase the processing efficiency, if a program in Linux runs multiple threads, the number of threads is closely related to the number of CPUs. For example, a 4-core CPU with 1 core is assigned to the main thread, and three cores are left. Therefore, only three other threads are required. In Windows, a large number of threads are usually used to handle this problem. Er ...... My current understanding is as follows. I don't know if it's right or not, and the underlying reasons for the specific difference are not clear ~ _~
Python 2.6 introduces a new multi-process processing module multiprocessing.
I am not very familiar with it.
It seems that the botnets have been directly solved internally. This is quite human: D.
In addition, the test also found that the singleton mode is still effective in multiple threads.
Because the member variables are saved in the heap, the parameter variables are saved in the stack.
For threads, stacks are independent, while stacks are shared.
So ...... It should be like this ~
Well, that's all. please correct me if there are any mistakes :)