File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,23 @@ def writer():
158
158
self .loop .add_writer (wsock , writer )
159
159
self .loop .run_until_complete (f )
160
160
161
+ def test_socket_sync_remove_and_immediately_close (self ):
162
+ # Test that it's OK to close the socket right after calling
163
+ # `remove_reader`.
164
+ sock = socket .socket ()
165
+ with sock :
166
+ cb = lambda : None
167
+
168
+ sock .bind (('127.0.0.1' , 0 ))
169
+ sock .listen (0 )
170
+ fd = sock .fileno ()
171
+ self .loop .add_reader (fd , cb )
172
+ self .loop .run_until_complete (asyncio .sleep (0.01 , loop = self .loop ))
173
+ self .loop .remove_reader (fd )
174
+ sock .close ()
175
+ self .assertEqual (sock .fileno (), - 1 )
176
+ self .loop .run_until_complete (asyncio .sleep (0.01 , loop = self .loop ))
177
+
161
178
162
179
class TestUVSockets (_TestSockets , tb .UVTestCase ):
163
180
You can’t perform that action at this time.
0 commit comments