@@ -768,13 +768,23 @@ def _register(self, ov, obj, callback):
768
768
f = _OverlappedFuture (ov , loop = self ._loop )
769
769
if f ._source_traceback :
770
770
del f ._source_traceback [- 1 ]
771
+ self ._register_early_out (f , ov , callback )
772
+ # Register the overlapped operation for later. Note that
773
+ # we only store obj to prevent it from being garbage
774
+ # collected too early.
775
+ self ._cache [ov .address ] = (f , ov , obj , callback )
776
+ return f
777
+
778
+ def _register_early_out (self , f , ov , callback ):
771
779
if not ov .pending :
772
780
# The operation has completed, so no need to postpone the
773
781
# work. We cannot take this short cut if we need the
774
782
# NumberOfBytes, CompletionKey values returned by
775
783
# PostQueuedCompletionStatus().
776
784
try :
777
785
value = callback (None , None , ov )
786
+ except _Retry as retry :
787
+ return self ._register_early_out (f , retry .ov , retry .callback )
778
788
except OSError as e :
779
789
f .set_exception (e )
780
790
else :
@@ -78
7972
5,12 +795,6 @@ def _register(self, ov, obj, callback):
785
795
# OVERLAPPED object, otherwise the memory is freed and Windows may
786
796
# read uninitialized memory.
787
797
788
- # Register the overlapped operation for later. Note that
789
- # we only store obj to prevent it from being garbage
790
- # collected too early.
791
- self ._cache [ov .address ] = (f , ov , obj , callback )
792
- return f
793
-
794
798
def _unregister (self , ov ):
795
799
"""Unregister an overlapped object.
796
800
0 commit comments