@@ -95,8 +95,9 @@ def __repr__(self):
95
95
96
96
class StreamWriter :
97
97
98
- def __init__ (self , s ):
98
+ def __init__ (self , s , extra ):
99
99
self .s = s
100
+ self .extra = extra
100
101
101
102
def awrite (self , buf ):
102
103
# This method is called awrite (async write) to not proliferate
@@ -130,6 +131,9 @@ def aclose(self):
130
131
yield IOWriteDone (self .s )
131
132
self .s .close ()
132
133
134
+ def get_extra_info (self , name , default = None ):
135
+ return self .extra .get (name , default )
136
+
133
137
def __repr__ (self ):
134
138
return "<StreamWriter %r>" % self .s
135
139
@@ -153,7 +157,7 @@ def open_connection(host, port):
153
157
assert s2 .fileno () == s .fileno ()
154
158
if __debug__ :
155
159
log .debug ("open_connection: After iowait: %s" , s )
156
- return StreamReader (s ), StreamWriter (s )
160
+ return StreamReader (s ), StreamWriter (s , {} )
157
161
158
162
159
163
def start_server (client_coro , host , port , backlog = 10 ):
@@ -176,7 +180,8 @@ def start_server(client_coro, host, port, backlog=10):
176
180
s2 .setblocking (False )
177
181
if __debug__ :
178
182
log .debug ("start_server: After accept: %s" , s2 )
179
- yield client_coro (StreamReader (s2 ), StreamWriter (s2 ))
183
+ extra = {"peername" : client_addr }
184
+ yield client_coro (StreamReader (s2 ), StreamWriter (s2 , extra ))
180
185
181
186
182
187
import uasyncio .core
0 commit comments