Search code examples
pythonpython-3.xpython-multithreadingcpu-cores

If a CPU core has two threads, how can let's say a loop in python send 50 requests at once if it's not a 25 core CPU?


If a CPU core has two threads, how can let's say a loop in python send 50 requests at once if it's not a 25 core CPU?


Solution

  • I remember my parallel computing programming course using MPI and while MPI was able to simulate the presence of several "processes" the degree of parallelism was limited by the number of processors in the parallel computing environment. Therefore, respect of your question, the answer is your Python loop is "simulating" the sending of 50 request at once because:

    "Threads refer to the highest level of code executed by a processor, so with many threads, your CPU can handle several tasks at the same time. All CPUs have active threads, and every process performed on your computer has at least a single thread."

    (https://whatsabyte.com/blog/processor-threads/)

    Today's High Speed processors can "make us feel" that the computer is running several things at the same time while it is truly running them sequentially.