kuuko pushed a commit to branch master. http://git.enlightenment.org/apps/epour.git/commit/?id=18299f202cf4105c18070673243c0015fb0302ed
commit 18299f202cf4105c18070673243c0015fb0302ed Author: Kai Huuhko <kai.huu...@gmail.com> Date: Wed Apr 15 14:44:03 2015 +0300 Use pop_alerts() instead of looping with pop_alert This saves CPU cycles on a busy session. --- epour/session.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/epour/session.py b/epour/session.py index 8164777..52471c7 100644 --- a/epour/session.py +++ b/epour/session.py @@ -1,7 +1,7 @@ # # Epour - A bittorrent client using EFL and libtorrent # -# Copyright 2012-2014 Kai Huuhko <kai.huu...@gmail.com> +# Copyright 2012-2015 Kai Huuhko <kai.huu...@gmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -393,7 +393,7 @@ class AlertManager(object): self.timer = Timer(self.update_interval, self.update) def callback_add(self, alert_type, cb, *args, **kwargs): - if not alert_type in self.alerts: + if alert_type not in self.alerts: self.alerts[alert_type] = [] self.alerts[alert_type].append((cb, args, kwargs)) @@ -405,7 +405,7 @@ class AlertManager(object): def signal(self, a): a_name = type(a).__name__ - if not a_name in self.alerts: + if a_name not in self.alerts: self.log.debug("No handler: {} | {}".format(a_name, a)) return @@ -416,13 +416,8 @@ class AlertManager(object): self.log.exception("Exception while handling alerts") def update(self): - # TODO: Use pop_alerts() #self.log.debug("Alerts TICK") - while 1: - a = self.session.pop_alert() - if not a: - break - + for a in self.session.pop_alerts(): self.signal(a) return True --