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:

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

----------
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 <rep...@bugs.python.org>
<http://bugs.python.org/issue29173>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to