10
10
11
11
log = logging .getLogger (__name__ )
12
12
13
-
14
- # This module uses ``yield from`` and ``@asyncio.coroutine`` over ``await`` and
15
- # ``async def`` for pre-Python-3.5 compatibility, so keep in mind that the
16
- # managed coroutines are generator-based, not native coroutines. See PEP 492:
17
- # https://www.python.org/dev/peps/pep-0492/#coroutine-objects
18
-
19
-
20
13
try :
21
14
asyncio .run_coroutine_threadsafe
22
15
except AttributeError :
@@ -40,9 +33,10 @@ def end(self):
40
33
'does not implement .end()' )
41
34
42
35
def __init__ (self , timeout , callback , loop ):
43
- delayed = self ._call_delayed_coro (timeout = timeout ,
36
+ delayed = asyncio . wait_for ( self ._call_delayed_coro (timeout = timeout ,
44
37
callback = callback ,
45
- loop = loop )
38
+ loop = loop ),
39
+ timeout = None )
46
40
self ._handle = asyncio .run_coroutine_threadsafe (delayed , loop = loop )
47
41
48
42
@staticmethod
@@ -96,10 +90,10 @@ def __init__(self, *args, **kwargs):
96
90
# see initialize_reactor -- loop is running in a separate thread, so we
97
91
# have to use a threadsafe call
98
92
self ._read_watcher = asyncio .run_coroutine_threadsafe (
99
- self .handle_read (), loop = self ._loop
93
+ asyncio . wait_for ( self .handle_read (), timeout = None ), loop = self ._loop
100
94
)
101
95
self ._write_watcher = asyncio .run_coroutine_threadsafe (
102
- self .handle_write (), loop = self ._loop
96
+ asyncio . wait_for ( self .handle_write (), timeout = None ), loop = self ._loop
103
97
)
104
98
self ._send_options_message ()
105
99
@@ -132,7 +126,7 @@ def close(self):
132
126
# close from the loop thread to avoid races when removing file
133
127
# descriptors
134
128
asyncio .run_coroutine_threadsafe (
135
- self ._close (), loop = self ._loop
129
+ asyncio . wait_for ( self ._close (), timeout = None ), loop = self ._loop
136
130
)
137
131
138
132
async def _close (self ):
@@ -165,7 +159,7 @@ def push(self, data):
165
159
166
160
if self ._loop_thread .ident != get_ident ():
167
161
asyncio .run_coroutine_threadsafe (
168
- self ._push_msg (chunks ),
162
+ asyncio . wait_for ( self ._push_msg (chunks ), timeout = None ),
169
163
loop = self ._loop
170
164
)
171
165
else :
0 commit comments