Why single python process's cpu usage can be more than 100 percent?

Viewed 4213

Because of GIL, I thought a multi-thread python process can only have one thread running at one time, thus the cpu usage can not be more than 100 percent.

But I found the code bellow can occupy 950% cpu usage in top.

import threading
import time

def f():
    while 1:
        pass


for i in range(10):
    t = threading.Thread(target=f)
    t.setDaemon(True)
    t.start()

time.sleep(60)

This is not a same question as Python interpreters uses up to 130% of my CPU. How is that possible?. In that question, the OP said he was doing I/O intensive load-testing which may release the GIL. But in my program, there is no I/O operation.

Tests run on CPython 2.6.6.

2 Answers
Related