[New-bugs-announce] [issue29173] Python 3.6 on Windows wastes a lot of CPU cycles in a while loop

Prahlad Yeri report at bugs.python.org
Thu Jan 5 18:28:45 EST 2017

New submission from Prahlad Yeri:

I'm running Python 3.6 on Windows 7. It wastes a lot of cpu cycles when inside a loop. In attached screenshot, you'll find that ~25% cpu is used by Python, while all I'm doing is running a pomodoro script that waits for a specific timeslot to complete. Here is the code for pomodoro.py that runs the while loop inside start_tracking() function:


def start_tracking(task):
	global last_beep
	print("Working on %s:%s (%d minutes)." % (task['category'], task['name'], task['duration']))
	print("Started tracking at %s." % (datetime.datetime.now().strftime("%H:%M")))
	print("Beep interval is set to %d minutes." % config.slot_interval)
	session_start_time = datetime.datetime.now()
	task_end_time = session_start_time + datetime.timedelta(minutes=task['duration'])
	last_beep = datetime.datetime.now()
	notified = False
		now = datetime.datetime.now()
		diff = (now - last_beep).total_seconds() / 60.0 #in minutes
		minutes_worked = round(diff)
		reminder_text = "%s:%s" % (task['category'], task['name'])
		#diff = diff.total_seconds() / (60.0) 
		if (diff >= config.slot_interval): #30

components: Windows
files: Python_high_CPU_Windows.png
messages: 284787
nosy: paul.moore, prahladyeri, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Python 3.6 on Windows wastes a lot of CPU cycles in a while loop
type: resource usage
versions: Python 3.6
Added file: http://bugs.python.org/file46169/Python_high_CPU_Windows.png

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list