Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/qasync/_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import asyncio
import sys
import threading

try:
import _overlapped
Expand Down Expand Up @@ -63,7 +64,7 @@
def __init__(self):
self.__events = []
super(_IocpProactor, self).__init__()
self._lock = QtCore.QMutex()
self._lock = threading.Lock()

def select(self, timeout=None):
"""Override in order to handle events in a threadsafe manner."""
Expand All @@ -81,50 +82,50 @@
# in the order they appear in the base class source code.

def recv(self, conn, nbytes, flags=0):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self).recv(conn, nbytes, flags)

def recv_into(self, conn, buf, flags=0):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self).recv_into(conn, buf, flags)

def recvfrom(self, conn, nbytes, flags=0):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self).recvfrom(conn, nbytes, flags)

Check warning on line 94 in src/qasync/_windows.py

View workflow job for this annotation

GitHub Actions / collect coverage

Missing coverage

Missing coverage on lines 93-94

def recvfrom_into(self, conn, buf, flags=0):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self).recvfrom_into(conn, buf, flags)

Check warning on line 98 in src/qasync/_windows.py

View workflow job for this annotation

GitHub Actions / collect coverage

Missing coverage

Missing coverage on lines 97-98

def sendto(self, conn, buf, flags=0, addr=None):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self).sendto(conn, buf, flags, addr)

Check warning on line 102 in src/qasync/_windows.py

View workflow job for this annotation

GitHub Actions / collect coverage

Missing coverage

Missing coverage on lines 101-102

def send(self, conn, buf, flags=0):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self).send(conn, buf, flags)

def accept(self, listener):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self).accept(listener)

Check warning on line 110 in src/qasync/_windows.py

View workflow job for this annotation

GitHub Actions / collect coverage

Missing coverage

Missing coverage on lines 109-110

def connect(self, conn, address):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self).connect(conn, address)

Check warning on line 114 in src/qasync/_windows.py

View workflow job for this annotation

GitHub Actions / collect coverage

Missing coverage

Missing coverage on lines 113-114

def sendfile(self, sock, file, offset, count):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self).sendfile(sock, file, offset, count)

Check warning on line 118 in src/qasync/_windows.py

View workflow job for this annotation

GitHub Actions / collect coverage

Missing coverage

Missing coverage on lines 117-118

def accept_pipe(self, pipe):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self).accept_pipe(pipe)

Check warning on line 122 in src/qasync/_windows.py

View workflow job for this annotation

GitHub Actions / collect coverage

Missing coverage

Missing coverage on lines 121-122

# connect_pipe() does not actually use the delayed completion machinery.

# This takes care of wait_for_handle() too.
def _wait_for_handle(self, handle, timeout, _is_cancel):
with QtCore.QMutexLocker(self._lock):
with self._lock:
return super(_IocpProactor, self)._wait_for_handle(
handle, timeout, _is_cancel
)
Expand All @@ -148,7 +149,7 @@
break
ms = 0

with QtCore.QMutexLocker(self._lock):
with self._lock:
err, transferred, key, address = status
try:
f, ov, obj, callback = self._cache.pop(address)
Expand Down
Loading