def cancel_pending_requests(self):
        '''Cancel all pending requests.'''
        exception = CancelledError()
        for _request, event in self._requests.values():
            event.result = exception
            event.set()
        self._requests.clear()
Cancel all pending requests.