[Pkg-bitcoin-commits] [python-quamash] 257/269: use Qt mutex instead of threading.Lock

Jonas Smedegaard dr at jones.dk
Fri Nov 24 11:26:42 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 6f829f57d3c23dbfc744876ae350c33670772fc8
Author: Peter Azmanov <peter.azmanov at transas.com>
Date:   Wed Nov 18 21:54:02 2015 +0300

    use Qt mutex instead of threading.Lock
---
 quamash/_windows.py | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/quamash/_windows.py b/quamash/_windows.py
index 510e0da..18afe81 100644
--- a/quamash/_windows.py
+++ b/quamash/_windows.py
@@ -5,7 +5,6 @@
 """Windows specific Quamash functionality."""
 
 import asyncio
-import threading
 
 try:
 	import _winapi
@@ -58,7 +57,7 @@ class _IocpProactor(windows_events.IocpProactor):
 	def __init__(self):
 		self.__events = []
 		super(_IocpProactor, self).__init__()
-		self._lock = threading.Lock()
+		self._lock = QtCore.QMutex()
 
 	def select(self, timeout=None):
 		"""Override in order to handle events in a threadsafe manner."""
@@ -73,11 +72,11 @@ class _IocpProactor(windows_events.IocpProactor):
 		super(_IocpProactor, self).close()
 
 	def recv(self, conn, nbytes, flags=0):
-		with self._lock:
+		with QtCore.QMutexLocker(self._lock):
 			return super(_IocpProactor, self).recv(conn, nbytes, flags)
 
 	def send(self, conn, buf, flags=0):
-		with self._lock:
+		with QtCore.QMutexLocker(self._lock):
 			return super(_IocpProactor, self).send(conn, buf, flags)
 
 	def _poll(self, timeout=None):
@@ -93,7 +92,7 @@ class _IocpProactor(windows_events.IocpProactor):
 			if ms >= UINT32_MAX:
 				raise ValueError("timeout too big")
 
-		with self._lock:
+		with QtCore.QMutexLocker(self._lock):
 			while True:
 				# self._logger.debug('Polling IOCP with timeout {} ms in thread {}...'.format(
 				# 	ms, threading.get_ident()))
@@ -121,15 +120,15 @@ class _IocpProactor(windows_events.IocpProactor):
 				ms = 0
 
 	def _wait_for_handle(self, handle, timeout, _is_cancel):
-		with self._lock:
+		with QtCore.QMutexLocker(self._lock):
 			return super(_IocpProactor, self)._wait_for_handle(handle, timeout, _is_cancel)
 
 	def accept(self, listener):
-		with self._lock:
+		with QtCore.QMutexLocker(self._lock):
 			return super(_IocpProactor, self).accept(listener)
 
 	def connect(self, conn, address):
-		with self._lock:
+		with QtCore.QMutexLocker(self._lock):
 			return super(_IocpProactor, self).connect(conn, address)
 
 

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