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 1
1
import asyncio
2
+ import select
2
3
import socket
3
4
import sys
4
5
import unittest
@@ -113,8 +114,30 @@ def test_socket_blocking_error(self):
113
114
114
115
115
116
class TestUVSockets (_TestSockets , tb .UVTestCase ):
116
- pass
117
117
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 ()
118
141
119
142
class TestAIOSockets (_TestSockets , tb .AIOTestCase ):
120
143
pass
Original file line number Diff line number Diff line change @@ -877,6 +877,10 @@ cdef class Loop:
877
877
878
878
return tcp
879
879
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
+
880
884
def print_debug_info (self ):
881
885
cdef:
882
886
int err
You can’t perform that action at this time.
0 commit comments