コード例 #1
0
    def connection_lost(self, exc):
        logger.debug('Connection %s lost!', self)

        if self.inactivity_timer:
            self.inactivity_timer.cancel()

        if self.on_connection_lost:
            self.on_connection_lost(self)

        closed_connection = ConnectionClosed()
        for request in self.requests.values():
            request.set_exception(closed_connection)
        self.free_channels.destroy(closed_connection)
コード例 #2
0
 async def send_notification(self, request):
     attempt = 0
     while True:
         attempt += 1
         if attempt > self.MAX_ATTEMPTS:
             logger.warning('Trying to send notification %s: attempt #%s',
                            request.notification_id, attempt)
         logger.debug('Notification %s: waiting for connection',
                      request.notification_id)
         try:
             connection = await self.acquire()
         except ConnectionError:
             logger.warning(
                 'Could not send notification %s: '
                 'ConnectionError', request.notification_id)
             await asyncio.sleep(1)
             continue
         logger.debug('Notification %s: connection %s acquired',
                      request.notification_id, connection)
         try:
             response = await connection.send_notification(request)
             return response
         except NoAvailableStreamIDError:
             connection.close()
         except ConnectionClosed:
             logger.warning(
                 'Could not send notification %s: '
                 'ConnectionClosed', request.notification_id)
         except FlowControlError:
             logger.debug('Got FlowControlError for notification %s',
                          request.notification_id)
             await asyncio.sleep(1)
コード例 #3
0
 def on_remote_settings_changed(self, changed_settings):
     for setting in changed_settings.values():
         logger.debug('Remote setting changed: %s', setting)
         if setting.setting == SettingCodes.MAX_CONCURRENT_STREAMS:
             self.free_channels.bound = setting.new_value
コード例 #4
0
 def discard_connection(self, connection):
     logger.debug('Connection %s discarded', connection)
     self.connections.remove(connection)
     logger.info('Connection released (total: %d)', len(self.connections))
コード例 #5
0
 def close(self):
     if self.inactivity_timer:
         self.inactivity_timer.cancel()
     logger.debug('Closing connection %s', self)
     self.transport._ssl_protocol._transport.close()