@@ -160,44 +160,42 @@ def test_fromfd(self):
160160 self .fail ("epoll on closed fd didn't raise EBADF" )
161161
162162 def test_control_and_wait (self ):
163+ # create the epoll object
163164 client , server = self ._connected_pair ()
164-
165165 ep = select .epoll (16 )
166166 ep .register (server .fileno (),
167167 select .EPOLLIN | select .EPOLLOUT | select .EPOLLET )
168168 ep .register (client .fileno (),
169169 select .EPOLLIN | select .EPOLLOUT | select .EPOLLET )
170170
171+ # EPOLLOUT
171172 now = time .monotonic ()
172173 events = ep .poll (1 , 4 )
173174 then = time .monotonic ()
174175 self .assertFalse (then - now > 0.1 , then - now )
175176
176- events .sort ()
177177 expected = [(client .fileno (), select .EPOLLOUT ),
178178 (server .fileno (), select .EPOLLOUT )]
179- expected .sort ()
180-
181- self .assertEqual (events , expected )
179+ self .assertEqual (sorted (events ), sorted (expected ))
182180
183- events = ep .poll (timeout = 2.1 , maxevents = 4 )
181+ # no event
182+ events = ep .poll (timeout = 0.1 , maxevents = 4 )
184183 self .assertFalse (events )
185184
186- client .send (b"Hello!" )
187- server .send (b"world!!!" )
185+ # send: EPOLLIN and EPOLLOUT
186+ client .sendall (b"Hello!" )
187+ server .sendall (b"world!!!" )
188188
189189 now = time .monotonic ()
190- events = ep .poll (1 , 4 )
190+ events = ep .poll (1.0 , 4 )
191191 then = time .monotonic ()
192192 self .assertFalse (then - now > 0.01 )
193193
194- events .sort ()
195194 expected = [(client .fileno (), select .EPOLLIN | select .EPOLLOUT ),
196195 (server .fileno (), select .EPOLLIN | select .EPOLLOUT )]
197- expected .sort ()
198-
199- self .assertEqual (events , expected )
196+ self .assertEqual (sorted (events ), sorted (expected ))
200197
198+ # unregister, modify
201199 ep .unregister (client .fileno ())
202200 ep .modify (server .fileno (), select .EPOLLOUT )
203201 now = time .monotonic ()
0 commit comments