@@ -26,7 +26,8 @@ async def wait_closed(self):
26
26
# TODO yield?
27
27
self .s .close ()
28
28
29
- async def read (self , n = - 1 ):
29
+ # async
30
+ def read (self , n = - 1 ):
30
31
r = b""
31
32
while True :
32
33
yield core ._io_queue .queue_read (self .s )
@@ -38,11 +39,13 @@ async def read(self, n=-1):
38
39
return r
39
40
r += r2
40
41
41
- async def readinto (self , buf ):
42
+ # async
43
+ def readinto (self , buf ):
42
44
yield core ._io_queue .queue_read (self .s )
43
45
return self .s .readinto (buf )
44
46
45
- async def readexactly (self , n ):
47
+ # async
48
+ def readexactly (self , n ):
46
49
r = b""
47
50
while n :
48
51
yield core ._io_queue .queue_read (self .s )
@@ -54,7 +57,8 @@ async def readexactly(self, n):
54
57
n -= len (r2 )
55
58
return r
56
59
57
- async def readline (self ):
60
+ # async
61
+ def readline (self ):
58
62
l = b""
59
63
while True :
60
64
yield core ._io_queue .queue_read (self .s )
@@ -73,10 +77,11 @@ def write(self, buf):
73
77
buf = buf [ret :]
74
78
self .out_buf += buf
75
79
76
- async def drain (self ):
80
+ # async
81
+ def drain (self ):
77
82
if not self .out_buf :
78
83
# Drain must always yield, so a tight loop of write+drain can't block the scheduler.
79
- return await core .sleep_ms (0 )
84
+ return ( yield from core .sleep_ms (0 ) )
80
85
mv = memoryview (self .out_buf )
81
86
off = 0
82
87
while off < len (mv ):
@@ -93,7 +98,9 @@ async def drain(self):
93
98
94
99
95
100
# Create a TCP stream connection to a remote host
96
- async def open_connection (host , port ):
101
+ #
102
+ # async
103
+ def open_connection (host , port ):
97
104
from uerrno import EINPROGRESS
98
105
import usocket as socket
99
106
0 commit comments