10
10
11
11
import asyncio
12
12
import sys
13
+ import threading
13
14
14
15
try :
15
16
import _overlapped
@@ -63,7 +64,7 @@ class _IocpProactor(windows_events.IocpProactor):
63
64
def __init__ (self ):
64
65
self .__events = []
65
66
super (_IocpProactor , self ).__init__ ()
66
- self ._lock = QtCore . QMutex ()
67
+ self ._lock = threading . Lock ()
67
68
68
69
def select (self , timeout = None ):
69
70
"""Override in order to handle events in a threadsafe manner."""
@@ -81,50 +82,50 @@ def close(self):
81
82
# in the order they appear in the base class source code.
82
83
83
84
def recv (self , conn , nbytes , flags = 0 ):
84
- with QtCore . QMutexLocker ( self ._lock ) :
85
+ with self ._lock :
85
86
return super (_IocpProactor , self ).recv (conn , nbytes , flags )
86
87
87
88
def recv_into (self , conn , buf , flags = 0 ):
88
- with QtCore . QMutexLocker ( self ._lock ) :
89
+ with self ._lock :
89
90
return super (_IocpProactor , self ).recv_into (conn , buf , flags )
90
91
91
92
def recvfrom (self , conn , nbytes , flags = 0 ):
92
- with QtCore . QMutexLocker ( self ._lock ) :
93
+ with self ._lock :
93
94
return super (_IocpProactor , self ).recvfrom (conn , nbytes , flags )
94
95
95
96
def recvfrom_into (self , conn , buf , flags = 0 ):
96
- with QtCore . QMutexLocker ( self ._lock ) :
97
+ with self ._lock :
97
98
return super (_IocpProactor , self ).recvfrom_into (conn , buf , flags )
98
99
99
100
def sendto (self , conn , buf , flags = 0 , addr = None ):
100
- with QtCore . QMutexLocker ( self ._lock ) :
101
+ with self ._lock :
101
102
return super (_IocpProactor , self ).sendto (conn , buf , flags , addr )
102
103
103
104
def send (self , conn , buf , flags = 0 ):
104
- with QtCore . QMutexLocker ( self ._lock ) :
105
+ with self ._lock :
105
106
return super (_IocpProactor , self ).send (conn , buf , flags )
106
107
107
108
def accept (self , listener ):
108
- with QtCore . QMutexLocker ( self ._lock ) :
109
+ with self ._lock :
109
110
return super (_IocpProactor , self ).accept (listener )
110
111
111
112
def connect (self , conn , address ):
112
- with QtCore . QMutexLocker ( self ._lock ) :
113
+ with self ._lock :
113
114
return super (_IocpProactor , self ).connect (conn , address )
114
115
115
116
def sendfile (self , sock , file , offset , count ):
116
- with QtCore . QMutexLocker ( self ._lock ) :
117
+ with self ._lock :
117
118
return super (_IocpProactor , self ).sendfile (sock , file , offset , count )
118
119
119
120
def accept_pipe (self , pipe ):
120
- with QtCore . QMutexLocker ( self ._lock ) :
121
+ with self ._lock :
121
122
return super (_IocpProactor , self ).accept_pipe (pipe )
122
123
123
124
# connect_pipe() does not actually use the delayed completion machinery.
124
125
125
126
# This takes care of wait_for_handle() too.
126
127
def _wait_for_handle (self , handle , timeout , _is_cancel ):
127
- with QtCore . QMutexLocker ( self ._lock ) :
128
+ with self ._lock :
128
129
return super (_IocpProactor , self )._wait_for_handle (
129
130
handle , timeout , _is_cancel
130
131
)
@@ -148,7 +149,7 @@ def _poll(self, timeout=None):
148
149
break
149
150
ms = 0
150
151
151
- with QtCore . QMutexLocker ( self ._lock ) :
152
+ with self ._lock :
152
153
err , transferred , key , address = status
153
154
try :
154
155
f , ov , obj , callback = self ._cache .pop (address )
0 commit comments