@@ -48,6 +48,7 @@ include "includes/stdlib.pxi"
48
48
include " errors.pyx"
49
49
50
50
cdef:
51
+ int PY39 = PY_VERSION_HEX >= 0x03090000
51
52
int PY37 = PY_VERSION_HEX >= 0x03070000
52
53
int PY36 = PY_VERSION_HEX >= 0x03060000
53
54
uint64_t MAX_SLEEP = 3600 * 24 * 365 * 100
@@ -3190,12 +3191,20 @@ class _SyncSocketReaderFuture(aio_Future):
3190
3191
self .__sock = sock
3191
3192
self .__loop = loop
3192
3193
3193
- def cancel (self ):
3194
+ def __remove_reader (self ):
3194
3195
if self .__sock is not None and self .__sock.fileno() != - 1 :
3195
3196
self .__loop.remove_reader(self .__sock)
3196
3197
self .__sock = None
3197
3198
3198
- aio_Future.cancel(self )
3199
+ if PY39:
3200
+ def cancel (self , msg = None ):
3201
+ self .__remove_reader()
3202
+ aio_Future.cancel(self , msg = msg)
3203
+
3204
+ else :
3205
+ def cancel (self ):
3206
+ self .__remove_reader()
3207
+ aio_Future.cancel(self )
3199
3208
3200
3209
3201
3210
class _SyncSocketWriterFuture (aio_Future ):
@@ -3205,12 +3214,20 @@ class _SyncSocketWriterFuture(aio_Future):
3205
3214
self .__sock = sock
3206
3215
self .__loop = loop
3207
3216
3208
- def cancel (self ):
3217
+ def __remove_writer (self ):
3209
3218
if self .__sock is not None and self .__sock.fileno() != - 1 :
3210
3219
self .__loop.remove_writer(self .__sock)
3211
3220
self .__sock = None
3212
3221
3213
- aio_Future.cancel(self )
3222
+ if PY39:
3223
+ def cancel (self , msg = None ):
3224
+ self .__remove_writer()
3225
+ aio_Future.cancel(self , msg = msg)
3226
+
3227
+ else :
3228
+ def cancel (self ):
3229
+ self .__remove_writer()
3230
+ aio_Future.cancel(self )
3214
3231
3215
3232
3216
3233
include " cbhandles.pyx"
0 commit comments