[Pkg-bitcoin-commits] [python-quamash] 204/269: Implement possible fix of notifiers being called out-of-order
Jonas Smedegaard
dr at jones.dk
Fri Nov 24 11:26:34 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository python-quamash.
commit e64119ebcca1dba10f43a959c6622823d5b04345
Author: Jonas Wielicki <j.wielicki at sotecware.net>
Date: Thu Jan 15 20:07:43 2015 +0100
Implement possible fix of notifiers being called out-of-order
---
quamash/__init__.py | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/quamash/__init__.py b/quamash/__init__.py
index a5daf0c..381daa5 100644
--- a/quamash/__init__.py
+++ b/quamash/__init__.py
@@ -435,6 +435,22 @@ class QEventLoop(_baseclass):
notifier.setEnabled(False)
return True
+ def __notifier_cb_wrapper(self, notifiers, notifier, fd, callback, args):
+ # This wrapper gets called with a certain delay. We cannot know
+ # for sure that the notifier is still the current notifier for
+ # the fd.
+ if notifiers.get(fd, None) is not notifier:
+ return
+ try:
+ callback(*args)
+ finally:
+ # The notifier might have been overriden by the
+ # callback. We must not re-enable it in that case.
+ if notifiers.get(fd, None) is notifier:
+ notifier.setEnabled(True)
+ else:
+ notifier.activated.disconnect()
+
def __on_notifier_ready(self, notifiers, notifier, fd, callback, args):
if fd not in notifiers:
self._logger.warning(
@@ -449,11 +465,9 @@ class QEventLoop(_baseclass):
assert notifier.isEnabled()
self._logger.debug('Socket notifier for fd {} is ready'.format(fd))
notifier.setEnabled(False)
- try:
- callback(*args)
- finally:
- if fd in notifiers:
- notifier.setEnabled(True)
+ self.call_soon(
+ self.__notifier_cb_wrapper,
+ notifiers, notifier, fd, callback, args)
# Methods for interacting with threads.
--
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