[Pkg-bitcoin-commits] [python-quamash] 200/269: QEventLoop as context manager no longer call `asyncio.set_event_loop`

Jonas Smedegaard dr at jones.dk
Fri Nov 24 11:26:33 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 0d0fceedf024a90d35a5c3cee269c485e1c6a4ec
Author: Mark Harviston <mark.harviston at gmail.com>
Date:   Thu Jan 15 15:09:18 2015 -0800

    QEventLoop as context manager no longer call `asyncio.set_event_loop`
    
    see #26 and #22
---
 README.rst          | 9 +++++++--
 quamash/__init__.py | 8 ++------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/README.rst b/README.rst
index b749d70..75d41b9 100644
--- a/README.rst
+++ b/README.rst
@@ -50,9 +50,10 @@ Usage
     from quamash import QEventLoop, QThreadExecutor
 
     app = QApplication(sys.argv)
-    progress = QProgressBar()
     loop = QEventLoop(app)
+    asyncio.set_event_loop(loop)  # NEW must set the event loop
 
+    progress = QProgressBar()
     progress.setRange(0, 99)
     progress.show()
 
@@ -74,12 +75,16 @@ Usage
             loop.call_soon_threadsafe(progress.setValue, i)
             time.sleep(.1)
 
-    with loop:
+    with loop: ## context manager calls .close() when loop completes, and releases all resources
         loop.run_until_complete(master())
 
 Changelog
 =========
 
+Upcoming/Unreleased Changes
+---------------------------
+* deprecation of event loop as means to ``asyncio.set_event_loop``, now must be called explicitly.
+
 Version 0.4.1
 -------------
 
diff --git a/quamash/__init__.py b/quamash/__init__.py
index fb689f1..ec3960f 100644
--- a/quamash/__init__.py
+++ b/quamash/__init__.py
@@ -549,15 +549,11 @@ class QEventLoop(_baseclass):
 		self.__debug_enabled = enabled
 
 	def __enter__(self):
-		asyncio.set_event_loop(self)
 		return self
 
 	def __exit__(self, *args):
-		try:
-			self.stop()
-			self.close()
-		finally:
-			asyncio.set_event_loop(None)
+		self.stop()
+		self.close()
 
 	@classmethod
 	def __log_error(cls, *args, **kwds):

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