My code has two jobs, the first consumes CPU 0.3%, the second consumes CPU 80%. The two jobs are repeatly worked like this:
while True:
job1()
job2()
I find after the first loop, the CPU consumption not down even if it worked in job1(), the consumption is always 80%.
So I modified the code like so:
n = 0
while True:
n += 1
if n > 1:
print 'to sleep'
time.sleep(100000000)
continue
job1()
job2()
I find the CPU consumption is 80% when it in sleep()
. Why did it happen?