[Pkg-bitcoin-commits] [python-quamash] 172/269: Fix removal of r/w-notifiers if another notifier is still bound

Jonas Smedegaard dr at jones.dk
Fri Nov 24 11:26:29 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 0d32e4ff17025ae2a7ce38ceaa82b2b495885d5a
Author: Jonas Wielicki <j.wielicki at sotecware.net>
Date:   Wed Dec 17 09:41:51 2014 +0100

    Fix removal of r/w-notifiers if another notifier is still bound
    
    I think this is a regression causd by c412687. That commit adds, a
    wrapper for the callback provided by the user. The workaround supplied
    by 43256c0 is not sufficient, and this commit aims to fix this.
    
    A common situation to trigger this is the asyncio-supplied SSL
    implementation.
---
 quamash/__init__.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/quamash/__init__.py b/quamash/__init__.py
index 3b30986..50673af 100644
--- a/quamash/__init__.py
+++ b/quamash/__init__.py
@@ -363,7 +363,8 @@ class QEventLoop(_baseclass):
 		notifier.setEnabled(True)
 		self._logger.debug('Adding reader callback for file descriptor {}'.format(fd))
 		notifier.activated.connect(
-			lambda: self.__on_notifier_ready(notifier, fd, callback, args)
+			lambda: self.__on_notifier_ready(self._read_notifiers,
+							 notifier, fd, callback, args)
 		)
 		self._read_notifiers[fd] = notifier
 
@@ -385,7 +386,8 @@ class QEventLoop(_baseclass):
 		notifier.setEnabled(True)
 		self._logger.debug('Adding writer callback for file descriptor {}'.format(fd))
 		notifier.activated.connect(
-			lambda: self.__on_notifier_ready(notifier, fd, callback, args)
+			lambda: self.__on_notifier_ready(self._write_notifiers,
+							 notifier, fd, callback, args)
 		)
 		self._write_notifiers[fd] = notifier
 
@@ -401,8 +403,8 @@ class QEventLoop(_baseclass):
 		else:
 			notifier.setEnabled(False)
 
-	def __on_notifier_ready(self, notifier, fd, callback, args):
-		if fd not in self._read_notifiers and fd not in self._write_notifiers:
+	def __on_notifier_ready(self, notifiers, notifier, fd, callback, args):
+		if fd not in notifiers:
 			self._logger.warning(
 				'Socket notifier for fd {} is ready, even though it should be disabled, not calling {} and disabling'
 				.format(fd, callback)
@@ -418,7 +420,8 @@ class QEventLoop(_baseclass):
 		try:
 			callback(*args)
 		finally:
-			notifier.setEnabled(True)
+			if fd in notifiers:
+				notifier.setEnabled(True)
 
 	# 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