[Pkg-bitcoin-commits] [python-quamash] 80/269: - more interesting demo application (IMO) - updated travis-ci to point to harvimt/quamash instead of aknuds1/quamash

Jonas Smedegaard dr at jones.dk
Fri Nov 24 11:26:18 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 26524175ddc487700858c38d400650b5bc461054
Author: Mark Harviston <mark.harviston at gmail.com>
Date:   Thu Jul 10 21:48:15 2014 -0700

    - more interesting demo application (IMO)
    - updated travis-ci to point to harvimt/quamash instead of aknuds1/quamash
---
 README | 60 +++++++++++++++++++++++++++++-------------------------------
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/README b/README
index a12620e..30a1cf3 100644
--- a/README
+++ b/README
@@ -5,8 +5,8 @@ Implementation of the `PEP 3156`_ Event-Loop with Qt
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 :author: Mark Harviston <mark.harviston at gmail.com>, Arve Knudsen <arve.knudsen at gmail.com>
 
-.. image:: https://travis-ci.org/aknuds1/quamash.png?branch=master
-    :target: https://travis-ci.org/aknuds1/quamash
+.. image:: https://travis-ci.org/harvimt/quamash.png?branch=master
+    :target: https://travis-ci.org/harvimt/quamash
 
 Requirements
 ============
@@ -16,42 +16,40 @@ Usage
 =====
 
 .. code:: python
-
-	import quamash
-	import time
-	import asyncio
 	import sys
+	import asyncio
+	import time
 
-	try:
-		from PyQt5.QtWidgets import QApplication, QMainWindow
-	except ImportError:
-		from PySide.QtGui import QApplication, QMainWindow
-
+	from PyQt5.QtWidgets import QApplication, QProgressBar
+	from quamash import QEventLoop, QThreadExecutor
 
-	def identity(x):
-		time.sleep(10)
-		return x
+	app = QApplication(sys.argv)
+	progress = QProgressBar()
+	loop = QEventLoop(app)
 
+	progress.setRange(0, 99)
+	progress.show()
 
 	@asyncio.coroutine
-	def my_task():
-		for x in range(5):
-			# Execute function in thread since it blocks
-			y = yield from loop.run_in_executor(None, identity, x)
-			assert x == y
+	def master():
+		yield from first_50()
+		with QThreadExecutor(1) as exec:
+			yield from loop.run_in_executor(exec, last_50)
+		# TODO announce complettion?
 
-		loop.stop()
-
-
-	if __name__ == '__main__':
-		app = QApplication(sys.argv)
-
-		win = QMainWindow()
-		win.show()
-
-		loop = quamash.QEventLoop(app)
-		with loop:
-			loop.run_until_complete(my_task())
+	@asyncio.coroutine
+	def first_50():
+		for i in range(50):
+			progress.setValue(i)
+			yield from asyncio.sleep(.1)
+
+	def last_50():
+		for i in range(50,100):
+			loop.call_soon_threadsafe(progress.setValue, i)
+			time.sleep(.1)
+
+	with loop:
+		loop.run_until_complete(master())
 
 Testing
 =======

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