Message284787
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 |
|
Date |
User |
Action |
Args |
2017-01-05 23:28:45 | prahladyeri | set | recipients:
+ prahladyeri, paul.moore, tim.golden, zach.ware, steve.dower |
2017-01-05 23:28:45 | prahladyeri | set | messageid: <1483658925.81.0.717567578019.issue29173@psf.upfronthosting.co.za> |
2017-01-05 23:28:45 | prahladyeri | link | issue29173 messages |
2017-01-05 23:28:45 | prahladyeri | create | |
|