File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 11import asyncio
2+ import select
23import socket
34import sys
45import unittest
@@ -113,8 +114,30 @@ def test_socket_blocking_error(self):
113114
114115
115116class TestUVSockets (_TestSockets , tb .UVTestCase ):
116- pass
117117
118+ @unittest .skipUnless (hasattr (select , 'epoll' ), 'Linux only test' )
119+ def test_socket_sync_remove (self ):
120+ # See https://github.com/MagicStack/uvloop/issues/61 for details
121+
122+ sock = socket .socket ()
123+ epoll = select .epoll .fromfd (self .loop ._get_backend_id ())
124+
125+ try :
126+ cb = lambda : None
127+
128+ sock .bind (('127.0.0.1' , 0 ))
129+ sock .listen (0 )
130+ fd = sock .fileno ()
131+ self .loop .add_reader (fd , cb )
132+ self .loop .run_until_complete (asyncio .sleep (0.01 , loop = self .loop ))
133+ self .loop .remove_reader (fd )
134+ with self .assertRaises (FileNotFoundError ):
135+ epoll .modify (fd , 0 )
136+
137+ finally :
138+ sock .close ()
139+ self .loop .close ()
140+ epoll .close ()
118141
119142class TestAIOSockets (_TestSockets , tb .AIOTestCase ):
120143 pass
Original file line number Diff line number Diff line change @@ -877,6 +877,10 @@ cdef class Loop:
877877
878878 return tcp
879879
880+ def _get_backend_id (self ):
881+ """ This method is used by uvloop tests and is not part of the API."""
882+ return uv.uv_backend_fd(self .uvloop)
883+
880884 def print_debug_info (self ):
881885 cdef:
882886 int err
You can’t perform that action at this time.
0 commit comments