This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author prahladyeri
Recipients paul.moore, prahladyeri, steve.dower, tim.golden, zach.ware
Date 2017-01-05.23:28:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1483658925.81.0.717567578019.issue29173@psf.upfronthosting.co.za>
In-reply-to
Content
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:

https://github.com/prahladyeri/PyPomodoro/blob/master/pomodoro.py



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
	while(True):
		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
			#notify
History
Date User Action Args
2017-01-05 23:28:45prahladyerisetrecipients: + prahladyeri, paul.moore, tim.golden, zach.ware, steve.dower
2017-01-05 23:28:45prahladyerisetmessageid: <1483658925.81.0.717567578019.issue29173@psf.upfronthosting.co.za>
2017-01-05 23:28:45prahladyerilinkissue29173 messages
2017-01-05 23:28:45prahladyericreate