MCPcopy Index your code
hub / github.com/python/cpython / _OverlappedFuture

Class _OverlappedFuture

Lib/asyncio/windows_events.py:49–94  ·  view source on GitHub ↗

Subclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation.

Source from the content-addressed store, hash-verified

47
48
49class _OverlappedFuture(futures.Future):
50 """Subclass of Future which represents an overlapped operation.
51
52 Cancelling it will immediately cancel the overlapped operation.
53 """
54
55 def __init__(self, ov, *, loop=None):
56 super().__init__(loop=loop)
57 if self._source_traceback:
58 del self._source_traceback[-1]
59 self._ov = ov
60
61 def _repr_info(self):
62 info = super()._repr_info()
63 if self._ov is not None:
64 state = 'pending' if self._ov.pending else 'completed'
65 info.insert(1, f'overlapped=<{state}, {self._ov.address:#x}>')
66 return info
67
68 def _cancel_overlapped(self):
69 if self._ov is None:
70 return
71 try:
72 self._ov.cancel()
73 except OSError as exc:
74 context = {
75 'message': 'Cancelling an overlapped future failed',
76 'exception': exc,
77 'future': self,
78 }
79 if self._source_traceback:
80 context['source_traceback'] = self._source_traceback
81 self._loop.call_exception_handler(context)
82 self._ov = None
83
84 def cancel(self, msg=None):
85 self._cancel_overlapped()
86 return super().cancel(msg=msg)
87
88 def set_exception(self, exception):
89 super().set_exception(exception)
90 self._cancel_overlapped()
91
92 def set_result(self, result):
93 super().set_result(result)
94 self._ov = None
95
96
97class _BaseWaitHandleFuture(futures.Future):

Callers 1

_registerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…