[Pkg-bitcoin-commits] [python-quamash] 142/269: Handle problem of remove_reader being called too many times

Jonas Smedegaard dr at jones.dk
Fri Nov 24 11:26:25 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 41948525528a04d6d8df15447c41545b43f227ae
Author: Arve Knudsen <arve.knudsen at gmail.com>
Date:   Sat Dec 6 21:21:09 2014 +0100

    Handle problem of remove_reader being called too many times
---
 quamash/__init__.py | 20 ++++++++++++++++----
 quamash/_unix.py    |  1 +
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/quamash/__init__.py b/quamash/__init__.py
index ea748c7..24bccc2 100644
--- a/quamash/__init__.py
+++ b/quamash/__init__.py
@@ -345,8 +345,14 @@ class QEventLoop(_baseclass):
 	def remove_reader(self, fd):
 		"""Remove reader callback."""
 		self._logger.debug('Removing reader callback for file descriptor {}'.format(fd))
-		notifier = self._read_notifiers.pop(fd)
-		notifier.setEnabled(False)
+		try:
+			notifier = self._read_notifiers.pop(fd)
+		except KeyError:
+			self._logger.warning(
+				'Attempt to remove non-existent reader callback for file descriptor {}'.format(fd)
+			)
+		else:
+			notifier.setEnabled(False)
 
 	def add_writer(self, fd, callback, *args):
 		"""Register a callback for when a file descriptor is ready for writing."""
@@ -361,8 +367,14 @@ class QEventLoop(_baseclass):
 	def remove_writer(self, fd):
 		"""Remove writer callback."""
 		self._logger.debug('Removing writer callback for file descriptor {}'.format(fd))
-		notifier = self._write_notifiers.pop(fd)
-		notifier.setEnabled(False)
+		try:
+			notifier = self._write_notifiers.pop(fd)
+		except KeyError:
+			self._logger.warning(
+				'Attempt to remove non-existent writer callback for file descriptor {}'.format(fd)
+			)
+		else:
+			notifier.setEnabled(False)
 
 	@staticmethod
 	def __on_notifier_ready(notifier, callback, args):
diff --git a/quamash/_unix.py b/quamash/_unix.py
index dbf6985..5883718 100644
--- a/quamash/_unix.py
+++ b/quamash/_unix.py
@@ -223,6 +223,7 @@ class _SelectorEventLoop(asyncio.SelectorEventLoop):
 		self._logger.debug('Waking on socket notification, {} signal callback(s) waiting'.format(
 			len(self._signal_safe_callbacks)
 		))
+
 		# Acknowledge command
 		self._ssock.recv(1)
 		for handle in self._signal_safe_callbacks[:]:

-- 
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