@@ -2277,6 +2277,12 @@ cdef class Loop:
2277
2277
if self ._debug and sock.gettimeout() != 0 :
2278
2278
raise ValueError (" the socket must be non-blocking" )
2279
2279
2280
+ # Remove the callback early. It should be rare that the
2281
+ # selector says the fd is ready but the call still returns
2282
+ # EAGAIN, and I am willing to take a hit in that case in
2283
+ # order to simplify the common case.
2284
+ self ._remove_reader(sock)
2285
+
2280
2286
fut = self ._new_reader_future(sock)
2281
2287
handle = new_MethodHandle3(
2282
2288
self ,
@@ -2303,6 +2309,12 @@ cdef class Loop:
2303
2309
if self ._debug and sock.gettimeout() != 0 :
2304
2310
raise ValueError (" the socket must be non-blocking" )
2305
2311
2312
+ # Remove the callback early. It should be rare that the
2313
+ # selector says the fd is ready but the call still returns
2314
+ # EAGAIN, and I am willing to take a hit in that case in
2315
+ # order to simplify the common case.
2316
+ self ._remove_reader(sock)
2317
+
2306
2318
fut = self ._new_reader_future(sock)
2307
2319
handle = new_MethodHandle3(
2308
2320
self ,
@@ -2354,6 +2366,12 @@ cdef class Loop:
2354
2366
data = memoryview(data)
2355
2367
data = data[n:]
2356
2368
2369
+ # Remove the callback early. It should be rare that the
2370
+ # selector says the fd is ready but the call still returns
2371
+ # EAGAIN, and I am willing to take a hit in that case in
2372
+ # order to simplify the common case.
2373
+ self ._remove_writer(sock)
2374
+
2357
2375
fut = self ._new_writer_future(sock)
2358
2376
handle = new_MethodHandle3(
2359
2377
self ,
@@ -2384,6 +2402,12 @@ cdef class Loop:
2384
2402
if self ._debug and sock.gettimeout() != 0 :
2385
2403
raise ValueError (" the socket must be non-blocking" )
2386
2404
2405
+ # Remove the callback early. It should be rare that the
2406
+ # selector says the fd is ready but the call still returns
2407
+ # EAGAIN, and I am willing to take a hit in that case in
2408
+ # order to simplify the common case.
2409
+ self ._remove_reader(sock)
2410
+
2387
2411
fut = self ._new_reader_future(sock)
2388
2412
handle = new_MethodHandle2(
2389
2413
self ,
0 commit comments