Exemple #1
0
 def _create_future(self) -> asyncio.Future:
     future = create_future(loop=self.channel.loop)
     future_id = id(future)
     self.async_futures[future_id] = future
     future.add_done_callback(
         lambda f: self.async_futures.pop(future_id, None))
     return future
Exemple #2
0
    def test_add_close_callback(self):
        client = yield from connect(AMQP_URL, loop=self.loop)

        f = create_future(loop=self.loop)

        client.add_close_callback(f.set_result)
        yield from client.close()

        self.assertTrue(f.done())
Exemple #3
0
    def on_reconnect(self, connection, channel_number):
        exc = ConnectionError('Auto Reconnect Error')

        if not self._closing.done():
            self._closing.set_exception(exc)

        self._closing = create_future(loop=self.loop)
        self._futures.reject_all(exc)
        self._connection = connection
        self._channel_number = channel_number

        yield from self.initialize()

        for exchange in self._exchanges.values():
            yield from exchange.on_reconnect(self)

        for queue in self._queues.values():
            yield from queue.on_reconnect(self)