示例#1
0
 def _on_channel_open(
     self,
     on_close: Optional[Callable[[pika.channel.Channel, Exception],
                                 Awaitable[None]]],
     channel: pika.channel.Channel,
 ) -> None:
     channel.add_on_close_callback(
         partial(self._on_channel_closed, on_close))
     if self._fut is None:
         raise RuntimeError()
     self._fut.set_result(channel)
示例#2
0
    def _create_channel(self, timeout=None):
        future = self._create_future(timeout=timeout)

        self._channel_maker(future.set_result)

        channel = yield from future  # type: pika.channel.Channel
        channel.confirm_delivery(self._on_delivery_confirmation)
        channel.add_on_close_callback(self._on_channel_close)
        channel.add_on_return_callback(self._on_return)

        return channel
示例#3
0
    def initialize(self, timeout=None) -> None:
        if self._closing.done():
            raise RuntimeError("Can't initialize closed channel")

        future = self._create_future(timeout=timeout)

        self.__connection._connection.channel(future.set_result)

        channel = yield from future  # type: pika.channel.Channel
        channel.confirm_delivery(self._on_delivery_confirmation)
        channel.add_on_close_callback(self._on_channel_close)

        self.__channel = channel
示例#4
0
    def _create_channel(self, timeout=None):
        future = self._create_future(timeout=timeout)

        self._channel_maker(future.set_result,
                            channel_number=self._channel_number)

        channel = yield from future  # type: pika.channel.Channel
        if self._publisher_confirms:
            channel.confirm_delivery(self._on_delivery_confirmation)

            if self._on_return_raises:
                channel.add_on_return_callback(self._on_return_delivery)

        channel.add_on_close_callback(self._on_channel_close)
        channel.add_on_return_callback(self._on_return)

        return channel