[Pkg-bitcoin-commits] [python-quamash] 51/78: Merge branch 'perfs' into gh66
Jonas Smedegaard
dr at jones.dk
Tue Dec 19 01:19:55 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/0.6.0_dfsg-1
in repository python-quamash.
commit 8026584fc9dc5ddd2b63be40d6e7835e43360573
Merge: 26da11d 40cc27e
Author: inso <insomniak.fr at gmaiL.com>
Date: Thu Nov 16 19:58:47 2017 +0100
Merge branch 'perfs' into gh66
quamash/__init__.py | 83 +++++++++++++++++++++++++++++------------------------
quamash/_windows.py | 3 --
2 files changed, 45 insertions(+), 41 deletions(-)
diff --cc quamash/__init__.py
index 94acfac,596ec5b..a3b7aaf
--- a/quamash/__init__.py
+++ b/quamash/__init__.py
@@@ -171,35 -170,51 +171,58 @@@ def _make_signaller(qtimpl_qtcore, *arg
return Signaller()
+if os.name == 'nt':
+ from . import _windows
+ _baseclass = _windows.baseclass
+else:
+ from . import _unix
+ _baseclass = _unix.baseclass
+
-
+ @with_logger
class _SimpleTimer(QtCore.QObject):
- def __init__(self, timeout, callback):
+ #__slots__ = 'callback', 'timer_id', 'stopped'
+ def __init__(self):
super().__init__()
- self.callback = callback
- self.timer_id = self.startTimer(timeout)
- self.stopped = False
+ self.__callbacks = {}
+ self._stopped = False
+
+ def add_callback(self, handle, delay=0):
+ #self._logger.debug('Adding callback {} with delay {}'.format(handle, delay))
+ #timer = _SimpleTimer(delay * 1000, upon_timeout)
+ #self.__timers.append(timer)
+ timerid = self.startTimer(delay * 1000)
+ self._logger.debug("Registering timer id {0}".format(timerid))
+ assert timerid not in self.__callbacks
+ self.__callbacks[timerid] = handle
+ return handle
def timerEvent(self, event): # noqa
- assert self.timer_id == event.timerId()
- if self.stopped:
- self.killTimer(self.timer_id)
- elif event.timerId() == self.timer_id:
- self.callback()
- self.killTimer(self.timer_id)
- self.stopped = True
+ timerid = event.timerId()
+ self._logger.debug("Timer event on id {0}".format(timerid))
+ if self._stopped:
+ self._logger.debug("Timer stopped, killing {}".format(timerid))
+ self.killTimer(timerid)
+ del self.__callbacks[timerid]
+ else:
+ try:
+ handle = self.__callbacks[timerid]
+ except KeyError as e :
+ self._logger.debug(str(e))
+ pass
+ else:
+ if handle._cancelled:
+ self._logger.debug("Handle {} cancelled".format(handle))
+ else:
+ self._logger.debug("Calling handle {}".format(handle))
+ handle._run()
+ finally:
+ del self.__callbacks[timerid]
+ handle = None
+ self.killTimer(timerid)
def stop(self):
- self.stopped = True
-
- def cancel(self):
- self.stopped = True
+ self._logger.debug("Stopping timers")
+ self._stopped = True
@with_logger
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/python-quamash.git
More information about the Pkg-bitcoin-commits
mailing list